Dataverse Web API Tip #1: The “Always Include” Headers

,

All HTTP requests to Microsoft’s Dataverse Web API should include, at minimum, the following four headers:

Accept: application/json 
OData-MaxVersion: 4.0 
OData-Version: 4.0
If-None-Match: null

The last one’s value can be confusing. By default, it should be set to a literal string with the text value of “null”, not a null value (e.g. headers.Add("If-None-Match", "null"), not headers.Add("If-None-Match", null)). (There are some special cases where you’ll deviate from this default value, but in all cases the header itself should always be sent.)

Additionally, if your request includes a JSON body, then be sure to include the appropriate content type header:

Content-Type: application/json

Or, even better, specify the charset, as well:

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

Reference

https://docs.microsoft.com/en-us/powerapps/developer/data-platform/webapi/compose-http-requests-handle-errors#http-headers

Leave a Reply

Your email address will not be published. Required fields are marked *