The HTTP header Content-Type is missing or its value is invalid error in REST API in SharePoint 2013/2016/Online

This SharePoint Rest API tutorial explains, how to solve “The HTTP header Content-Type is missing or its value is invalid” error which comes in Rest API in SharePoint 2013.

Recently I am trying to retrieve some information using SharePoint 2013 REST API. I wrote the code like below:

headers: {
"accept": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
}

But it gave me error like:
Microsoft.SharePoint.Cient.ClientServiceException. The HTTP header Content Type is missing or its value is invalid. Unsupported Media Type. The error looks like below:

The HTTP header Content Type is missing or its value is invalid
The HTTP header Content Type is missing or its value is invalid

The HTTP header Content Type is missing or its value is invalid

The error was coming because content-type was missing and it got resolved by adding the below line:

"content-type": "application/json;odata=verbose"

The full code looks like below:

headers: {
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose",
"X-RequestDigest": $("#__REQUESTDIGEST").val()
}

You may like following SharePoint rest API tutorials:

Hope this SharePoint tutorial helps to resolve, The HTTP header Content-Type is missing or its value is invalid error in REST API in SharePoint 2013/2016/Online

Donwload Hub site pdf

Download SharePoint Online Tutorial PDF FREE!

Get update on Webinars, video tutorials, training courses etc.

>