I'm getting a response from an API call and I'm using the HttpRequestMessage to set up my "get" request and then HttpClient to stream the response and return a string. However, within the response, I'm getting \u2019 instead of ' and in when I convert this result into excel (using JsonConvert and CsvWriter), I'm getting ’ instead of ' in my csv. Do I miss something at the headers level when requesting the API's response ?
public static string GetResponse_CFRA(string oauth2_token, string apiKey, string uri)
{
var httpRequestMessage = new HttpRequestMessage
{
Method = HttpMethod.Get,
RequestUri = new Uri(uri),
Headers = {
{ "Authorization", $"Bearer {oauth2_token}"},
{ "x-api-key", apiKey}
}
};
// Get the response from the API
using (var client = new HttpClient())
{
try
{
var response = client.SendAsync(httpRequestMessage).Result;
HttpContent responseContent = response.Content;
var responsedata = responseContent.ReadAsStringAsync();
string data = responsedata.Result;
return data;
}
catch
{
string sorry = "Please call the admin";
return sorry;
}
}
}