none
Best practice for development using REST API - OData RRS feed

  • Question

  • Hi All, I am new to REST. I am a developer who works mostly in server-side code using Visual Studio. Now that Microsoft is advocating to write code using REST API instead of server-side code or client side object model, I am trying to use REST API. I googled and most of the example shows to write a code and put it on Content Editor/Script Editor. How to organize code and deploy to the staging/production in this scenario? Is there any Best Practice or example around this?

    Regards,


    Khushi

    Wednesday, February 5, 2014 10:54 PM

Answers

All replies

  • Good to start with here http://www.restapitutorial.com/

    --Cheers

    Thursday, February 6, 2014 6:00 AM
  • Thanks Prasath for sharing useful resource. But my question was - Where in SharePoint we should write REST code? Is Content Editor a proper place to put REST code? As I mentioned that I had being a developer and writes server-side code in web part, events, timer jobs etc. using Visual Studio and build and deploy the package in other environment. I am trying to understand how we will port REST code from one environment to another?

    Regards,


    Khushi

    Thursday, February 6, 2014 1:04 PM
  • You can write Rest API code in aspx and cs files. Refer to the following post, and download sample code from gallery.

    http://msdn.microsoft.com/en-us/library/jj901637.aspx


    --Cheers

    Thursday, February 6, 2014 1:32 PM
  • Prasath - Thanks again for pointing me to another good resource. Still I am confused. So, this all Client-side development talk and that you don't have to deploy anything on server, no need to reset IIS, etc. I am seeing no connection in talk and the actual implementation on live site. If I am writing REST API code in aspx and cs that have to be deployed to the server. What's the purpose of writing code in REST and why not writing same thing using server-side object model? In both the cases we need to build a package and deploy on live environment and ofcourse would need to reset the IIS. I am looking for the best practice writing code RES API. Where should I write code and how would it be deploy without resetting the IIS. I am looking for the actual reason and proper utilization of REST API. For example. I need to make changes in UI viz. master page. In 2010 we did create custom master page and create a feature build the package and deployed on the production server. We created web parts (Some of those web parts - I can now develop using REST API) using server-side code and wrap in package and deployed. I saw few demos by evangelists writing code in Content Editor and Volla displaying list items from cross-Site collections. Is that a good practice?

    Sorry so many question but I think before dive into 2013 development I need to understand the proper way of doing it.

     Regards,

    Khushi

    Thursday, February 6, 2014 4:08 PM
  • If you are writing code in aspx or cs it does not mean that you need to deploy it in the SharePoint server, it could be any other application running from your remote server. What I mean it you can use C# & Rest API to connect to SharePoint server.

    REST API in SharePoint 2013 provides the developers with a simple standardized method of retrieving information from SharePoint and it can be used from any technology that is capable of sending standard HTTP requests.

    Refer to the following blog that provide your more details about comparison of the major features of these programming choices/

    http://msdn.microsoft.com/en-us/library/jj164060.aspx#RESTODataA

    http://dlr2008.wordpress.com/2013/10/31/sharepoint-2013-rest-api-the-c-connection-part-1-using-system-net-http-httpclient/

    Hope this helps


    --Cheers

    Friday, February 7, 2014 4:22 AM