SP 2013: The HTTP header ACCEPT is missing or its value is invalid – solution
Posted by Tobias Zimmergren
Author: Tobias Zimmergren
http://www.zimmergren.net | http://www.tozit.com | @zimmergren
Introduction
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.
Description & Solution
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.


Pingback: SharePoint Daily » Blog Archive » Preparing for SharePoint 2013; Cloud Collaboration, Social & Docs; Make the Switch to Office 365
Pingback: Preparing for SharePoint 2013; Cloud Collaboration, Social & Docs; Make the Switch to Office 365 - SharePoint Daily - Bamboo Nation