I'm using a central API in ASP.Net Core to authenticate users and to create JSON Web Tokens. The central API, in turn, calls other APIs to get other data, such as user profile data and subscription information. However, the central API receives double-serialized JSON objects that I cannot seem to deserialize. Here's the code from the central API:
Request.Host = new HostString(_usersApi);
HttpRequestMessageFeature hreqmf = new HttpRequestMessageFeature(HttpContext);
HttpRequestMessage httpRequestMessage = hreqmf.HttpRequestMessage;
var client = new HttpClient();
var response = await client.SendAsync(httpRequestMessage,
HttpCompletionOption.ResponseHeadersRead);
var data = response.Content.ReadAsStringAsync();
var deserialized = JsonConvert.DeserializeObject<MyObject>(data.Result);
return Ok(deserialized);
data.Result
equals "{\"property1\":\"value1\",\"property2\":\"value2\"}"
I cannot deserialize it to
{"Property1": "value1", "Property2": "value2"}
What am I missing? Thanks.