This project has moved and is read-only. For the latest updates, please go here.

How do I use REST?

Dec 29, 2013 at 5:29 PM
I discovered SPServices in October and I've created an application completely based on this library. However, I keep coming across people telling me I should be using REST instead of SOAP and that REST is the future of SP. Can anyone give me an example of how I'm suppose to change my code to use rest instead of SOAP? Is REST something that's part of SPServices or completely different?

For example, I have this function here which get's me user information for a site collection. How could I accomplish the same thing using REST?
 function populateUsers() {
    //Populate the user list
    strHTMLSiteUsers = "";
    $("#my_SiteUsers option:gt(0)").remove(); //remove all except first
        operation: "GetUserCollectionFromSite",
        completefunc: function(xData, Status) {
          userCollection = $(xData.responseXML);
          userCollection.find("User").each(function() {
            strHTMLSiteUsers += "<option value='" + $(this).attr("LoginName") + "' data-userid='"+ $(this).attr("ID")+ "'>" + $(this).attr("Name") + "</option>";
Dec 29, 2013 at 6:31 PM
REST is a Sharepoint API that MS introduced with SP2010 and yes, it is the future preferred method of interacting with sharepoint content. SPServices is a wrapper (value added function aside) around the SharePoint SOAP API abstracting that API as a jQuery Plugin. It does not offer a wrapper around the REST API - but do a quick Google/Bing search and you will find several guides on how to use the SP REST API.

NOTE: although you should develop new solutions using the REST API (specially if on SP2013), the existing SOAP API will continue to work for the foreseeable future and continues to be the preferred API if targeting a solution that must work across SP versions - SP2007, 2010, 2013.



Paul T

Dec 30, 2013 at 3:50 PM
Excellent response, Paul, and basically exactly what I would have said.