Looking for something?

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.

0 Comments 26 December 2012
Tobias Zimmergren

Tobias Zimmergren

Hi, I'm Tobias. I am a Microsoft MVP for SharePoint and I use this site to share my thoughts on tech with you on topics like SharePoint, Office 365, Azure and general web development.

  Malmö, Sweden

Related Post

Comments powered by Disqus
res.