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 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:
- Create custom SharePoint Survey poll using REST API and AngularJS
- Create a Custom People Directory using REST API in SharePoint
- Retrieve and Display TASK status using REST API in SharePoint
- Create a Custom Calendar in SharePoint using Rest API and jQuery
- Create custom announcement web part using Rest API in SharePoint Online/2013/2016
- Create SharePoint Quote of the day web part using Rest API and Bootstrap
- Add Google ReCaptcha in SharePoint Online or SharePoint 2013/2016/2019 (Step by Step tutorial)
- Display Task List data in a table using SharePoint REST API and filter by status column
- SharePoint 2016 crud operations using Rest API and jQuery on list or document library
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
I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SPGuides.com