I have a xamarin.forms app which have a GET Api URL like this
sampleurl.com/my-app-data/requests?orderBy=-created_at&related=user,+role&perPage=100
This were working fine on Andorid and iOS 16.But after iOS 17, The "?" getting changed to "%" in the URL like this.
sampleurl.com/my-app-data/requests%orderBy=-created_at&related=user,+role&perPage=100
which causing error. I guessing that after iOS 17 apple introduced a url parsing behaviour which causing this.How we can tackle this issue?
My code resposible for handling API call is following
var client = new HttpClient { BaseAddress = baseAddress };
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var current = Connectivity.NetworkAccess;
if (receivedMethod == APIMethodConstants.GET)
{
req = new HttpRequestMessage(HttpMethod.Get, apiurl);
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("bearer", JwtToken);
Task<string> task = Task.Run(async () => await Threading(client, req));
task.Wait();
stringObtained = task.Result;
jsonObtained = stringObtained;
}
async Task<string> Threading(HttpClient client, HttpRequestMessage req)
{
WebUtility.UrlDecode(req.RequestUri.ToString());
var resp = await client.SendAsync(req);
switch (resp.StatusCode)
{
//rest logic
}
return stringObtained;
}
Any help is appriciated.
I tried making my URL build using URIBuilder and things and none worked for iOS 17. I changed the HttpClient Implementation into
ManagedfromNsUrlSession, all my problematic APIs are started working in iOS 17.I think this may be a temporary solution, because changing it intoManagedmay cause performance issues . Will update if any other way found.