I am trying to return a JSON for the Web API I am building. The API returns the JSON with \ slashes that makes difficult for my other application to consume this API.
" {\"@odata.context\":\"https://science.com/odata/$metadata#EMPLOYEE\",\"value\":[{\"Id\":5000004,\"Name\":\"Account\"}]}"
But I am expecting a response like
{
"@odata.context": "https://science.com/odata/$metadata#EMPLOYEE",
"value": [
{
"Id": 5000004,
"Name": "Account"
}]}
Below is the code for my Web API
public async Task<string> GetEmployee(string instance)
{
.....
EmployeeDTO.RootObject returnObj = new EmployeeDTO.RootObject();
var responsedata = "";
try
{
using (var client_Core = new HttpClient())
{
....
string core_URL = BaseURL_Core+URL_instance;
var response = client_Core.GetAsync(core_URL).Result;
responsedata = await response.Content.ReadAsStringAsync();
}
}
catch (Exception ex)
{
throw ex;
}
return responsedata;
}
I have also added the Content type in the WebAPIConfig file like below
var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml");
config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
But I am still getting the JSON with the slashes
\s?