1
I am consuming an api but the return JSON does not come with the correct accent. in place of the mirror comes %20, for example.
in the request json I even put the encoding.UFT8.
How can I code this correctly?
private string jsonRequest = @"{'action': {'name': 'get_user_drivers','parameters': [{'driver_id': '','active_drivers': '','group_id': '','version': ''}],'session_token': '" + Helpers.TraffilogLogin.GetAuthToken() + "'}";
var content = new StringContent(jsonRequest , Encoding.UTF8, "application/json");
content.Headers.Clear();
content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
HttpClient httpClientInstance = new HttpClient();
var response = httpClientInstance.PostAsync(BaseApi.traffilogApiUrl, content).Result;
JArray groupListJson = (JArray)JObject.Parse(response.Content.ReadAsStringAsync().Result)["response"]["properties"]["data"];
I didn’t understand. This url is the answer or the url of the same api?
– Bruno Jose da Costa
It is the answer, the name of the method is
UrlDecode
Because you usually use Percent-encoding for URL, the answer you receive is fully encoded or just some attributes? for example a url field. Edit the question with the sample coded answer.– Leonardo Bonetti
But in response, you would pass like this:
string decodedUrl = HttpUtility.UrlDecode(RESPOSTA);
– Leonardo Bonetti
I edited the question with the code I’m using. Where would I use this Urldecode? They’re not all characters. So far I’ve noticed it’s space, two dots, c, ~
– Bruno Jose da Costa
Enter the answer you receive, like the pure JSON knows?
– Leonardo Bonetti
Is this Httputility from System.Web? I can’t find its reference.
– Bruno Jose da Costa
I got it. I’m using console app so it’s another name space: System.Net.Webutility.Urldecode(string)
– Bruno Jose da Costa