Fixing: The HTTP header ACCEPT is missing or its value is invalid - SharePoint 2013
So just a simple tip in case anyone bumps into the same issue as I had a while back. Going from Beta to RTM, some things changed in the way you retrieve values using REST in the SharePoint 2013 client object model.
In the older versions of the object model, you could simply use something like this in your REST call:
$.ajax( { url: SPSearchResults.url, method: "GET", headers: { "accept": "application/json", }, success: SPSearchResults.onSuccess, error: SPSearchResults.onError } );
As you can see the headers
is specifying application/json
.
The fix is simply to swap that statement into this:
$.ajax( { url: SPSearchResults.url, method: "GET", headers: { "accept": "application/json;odata=verbose", }, success: SPSearchResults.onSuccess, error: SPSearchResults.onError } );
And that’s a wrap.
Summary
I hope this can save someone a few minutes (or more) of debugging for using old example code or ripping up older projects. I’ve found that a lot of examples online, based on the beta of SharePoint 2013, are using the older version of the headers-statement which inevitably will lead to this problem. So with that said, enjoy.
Recent comments