'OData POST To Dynamics 365 Web API C#

I am trying to send a POST to the web api for Dynamics 365 using C#. However I am getting the error.

400 Bad Request

My content looks like this

{
  "[email protected]": "/accounts(4b6676f1-2c31-ea11-a810-000d3a23e249)",
  "new_name": "10012071567 - Fibre - ",
  "new_uprn": "10012071567"
}

The code is here

HttpRequestMessage request1 = new HttpRequestMessage(HttpMethod.Post, "/api/data/v9.1/entityname");
request1.Content = new StringContent(eoi.ToString(), Encoding.UTF8, "application/json");
request1.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
HttpResponseMessage response2 = client.SendAsync(request1).Result;

Any ideas what is wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source