Search code examples
restdynamics-crmodatamicrosoft-dynamics

D365 API PATCH call returns 204 No Content


I am making a call to Dynamics 365 incidents entity and I am updating few fields like 'notes' by passing the key value in Body of the HTTP call. URL is something like below:

PATCH https://<>.crm.dynamics.com/api/data/v9.0/incidents(e34d7dd4-b0cc-4e6d-a8e4-9a18b3341830)

The call works via Postman and returns a status code of 204 No Content.

enter image description here

I get it that the operation was successful and there was no content to return, hence the status. But is there any way to return 1 or many fields in response by modifying the request in postman, like we do in a GET call by passing below query param. I mean returning some values in response with 200 ok, will be helpful. That will also help with C# implementation.

$select=incidentid,notes

  1. Also when is it required to pass below header values in D365 API calls. The above call works without adding these headers.

OData-MaxVersion:4.0

OData-Version:4.0

Accept:application/json

Content-Type:application/json; charset=utf-8

  1. I am not a Dynamics 365 person, so while exploring for these questions, I couldn't find any documentation that would guide us in making the REST API calls with some samples. Doesn't Microsoft have any documentation for that.

Solution

  • The header

    "Prefer": "return=representation"

    will return the record after the PATCH call, I am not aware of a similar functionality using the C# SDK (so if you use the C# SDK you will need to do a Retrieve after the Update).

    You can use my tool Dataverse REST Builder to generate Web API calls.