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

Sathish Nadarajan
SharePoint MVP
Published On :   26 May 2014
Visit Count
Today :  2    Total :   12994
Plan, Migrate, Secure, Report
SharePoint & Office 365 Tool. Simple & Easy to Use. 15-Day Trial!

SharePoint Office 365 Tool
Simple & Powerful Tool for Migration, Security & Reporting. Free Trial

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.

SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.

Protect Your SharePoint