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
While JSON doesn't support comments, comments work in that json file. I prefix them with //
Using appsettings.json instead of web.config in .NET Core projects · 2 months ago
Nice one, was helpful :)
Enable thorough monitoring with Azure Monitor for you Azure Kubernetes Services (AKS) cluster · 4 months ago
Hi Tobias, I have noticed that the secure score over time graph does not take into account the last record recorded per...
Track your Azure Secure Score over time · 6 months ago
Pipeline update with the nuget.config worked for me .
Fixing the NuGet 401 Unauthorized issues from private repositories · 6 months ago
(This is an older post I realize) but the Az Powershell module has (as you would expect),
Generate Bicep templates from existing Azure resources with VS Code · 7 months ago
hey, thanks for the gif demo, ur fast as fuck
Developing with Azure Resources - Check out Azure Resource Explorer · 7 months ago