The HTTP Header ACCEPT is missing or its value is invalid – SharePoint 2013

Sathish Nadarajan
Solution Architect
May 26, 2014
Rate this article
[Total: 0    Average: 0/5]

A common exception when make an ajax call and get back the value as a JSON object. “The HTTP Header ACCEPT is missing or its value is invalid”. Let us see a solution for this.

The piece of code which I tried to make an ajax call is as follows.

 function executeQuery(queryTerms)
     Results = {
         element: '',
         url: '',
         init: function (element) {
             Results.element = element;
             Results.url = _spPageContextInfo.webAbsoluteUrl + "/_api/search/query?querytext='" + queryTerms + "'";
         load: function () {
                 method: "GET",
                 headers: { "ACCEPT": "application/json " },
                 success: Results.onSuccess,
                 error : Results.onError
         onError: function (error) {
         onSuccess: function (data) {
 //Do whatever you want

When I execute I get the above mentioned error. The screen shot is as follows.


The solution is very simple. By appending the HEADER as below will resolve this exception.

headers: { "ACCEPT": "application/json;odata:verbose " },

Happy Coding.

Sathish Nadarajan.

Category : SharePoint

Author Info

Sathish Nadarajan
Solution Architect
Rate this article
[Total: 0    Average: 0/5]
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 13+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business more

Leave a comment