Wednesday, November 28, 2012

SharePoint 2013 REST Library

As part of his TypeScript presentation at SharePoint Conference 2012, Rob Bogue had to do a lot of work with the new REST API's for SharePoint 2013 (as we all did).   Not happy to simply sling a bunch of JavaScript and call it a day, Rob took things a step further and created a reference library implementation to make things a bit easier on all of us.

Wiring up a REST query from a provider-hosted app to SharePoint 2013 looks like this if you set up the call and handle results manually:

var executor = new SP.RequestExecutor(appWebUrl);
var reqUrl = appWebUrl + "/_api/SP.AppContextSite(@target)/web/lists/getbytitle('" + myList + "')/items?$select=Title&@target='" + hostWebUrl + "'";
 url: reqUrl,
 method: "GET",
 headers: { "Accept": "application/json;odata=verbose" },
 success: function (result) {
  var objData = $.parseJSON(result.body);
  response($.map(objData.d.results, function (item) {
   return {
    label: item.Title
 error: function (result, code, message) {

Using SP REST, the syntax is much cleaner and easier to read (and if you're using TypeScript you also get full Intellisense support):

   field: 'Title',
   operator: 'eq',
   value: obj.myValue
}]).done(function (items) { //Do Something Here });

Rob is releasing SP REST to the community and is asking for contributors to help take the project forward.  If you're interested, contact Rob via his blog and jump on the SP REST bandwagon.


Ten Steps to Optimize SharePoint Performance


Secrets of SharePoint Part 5: Configuring Microsoft Office SharePoint Server 2007 for Optimal Performance
Creating End User SharePoint Solutions for Performance and Scalability 
SharePoint 2010 Performance Enhancements for Administrators
Microsoft SharePoint Server 2010 for the ASP.NET Developer
Following Best Practices and Avoiding Common Errors with Microsoft Office SharePoint Server 2007 Development
SharePoint Performance and Capacity Planning Essentials
Troubleshooting Common Performance Problems in SharePoint 2010


Channel 9 Interview with Eric Shupps
SharePoint TechTalk - Different Views on Social Computing
SharePoint Post-Deployment Planning and Management


SharePoint Pod Show - Design for Performance
SharePoint Pod Show - Test Driven Development
Run As Radio - Eric Shupps Improves SharePoint Performance