none
SharePoint Rest Service RRS feed

  • Question

  • Hello All,

    Can you please let me know step by step proecdure on how to create , build and host a Sharepoint 2013 REST Service?

    i also want to perform some crude operations on list, files and folders like create, update, read and delete.

    I want to do the REST service code in .net.

    Please update me on above.

    Thanks,

    Sushil


    sushil sahu


    • Moved by Hemendra Agrawal Monday, July 29, 2013 8:09 AM SP 2013
    • Edited by sushil sahu Monday, July 29, 2013 11:33 AM added one more line
    Monday, July 29, 2013 7:15 AM

Answers

All replies

  • Hi Sushil,

    Please check the following article about How to complete basic operations using SharePoint 2013 REST endpoints,

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

    Best Regards.


    Kelly Chen
    TechNet Community Support

    Tuesday, July 30, 2013 2:03 AM
    Moderator
  • Here you go:

    1. Create REST Service: http://ranaictiu-technicalblog.blogspot.com.au/2011/03/sharepoint-2010-create-custom-wcf.html
    2. Use the REST service using jquery: http://ranaictiu-technicalblog.blogspot.com.au/2011/09/sharepoint-2010-access-wcf-service-with.html

    One point here, if you would like to use different REST endpoints, you can do so with 'WebGet' or 'WebInvoke' attribute and you can get the idea from the link: http://ranaictiu-technicalblog.blogspot.com.au/2013/04/sharepoint-2013-workflow-use-httpsend.html


    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com>

    Tuesday, July 30, 2013 3:53 AM
  • Hi All, Thanks for your replies.

    Actually I need reference code to create Rest Services and client application to call these Rest servies to perform crud operations on SharePoint lists, files and folders.

    SharePoint provides its own web services, so whether it is a Soap based or Rest based ?

    And can I call these web services provided by SharePoint itself using c#? and how to call them

    Kindly let me know.

    Thanks in advance,

    Sushil


    sushil sahu

    Tuesday, July 30, 2013 7:37 AM
  • Hi,

    what do you mean 'Create REST Service'? Do you want to create a custom WCF service deployed it in SharePoint? Or you want to create a REST service proxy sing Visual Studio service reference?

    SharePoint 2013 ,provides both soap based and rest based. all asmx services are soap based and wcf services are rest based.

    If you want to use SharePoint provided REST services, without creating custom one, you can use the service reference directly in Visual Studio, which will create a service proxy automatically for you. However, in that case the service will hide the REST syntax from you and provide C# methods. If you still need to access it in RESTful way, you can take a look at: http://msdn.microsoft.com/en-us/library/jj164022.aspx


    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com>

    Tuesday, July 30, 2013 8:42 AM
  • Thanks Sohel,

    Means SharePoint provides REST Services also for CRUD operations? I found only Soap based services in SharePoint.

    If it so that it provides REST based Services also then I think I don't need to create custom REST Services.

    I got the list of SOAP based services in SharePoint by just putting the "_vti_bin/Lists.asmx" path at the end of my list name in the browser and I got all the services provided by SharePoint but these were SOAP based.

    So if there are REST services also for crud operations provided by SharePoint then please let me know where and how should I get them and how should I call them to perform CRUD operations on lists, files and folders.

    And if there are REST services also for crud operations provided by SharePoint then I want to make my client application in c-sharp to call them.

    I am very new to this, Kindly let me know how should I achieve this.

    Thanks in advance,

    Sushil


    sushil sahu

    Tuesday, July 30, 2013 9:33 AM
  • Hi,

    If you are using C# then why not using 'Managed Client Object Model' instead of REST? Managed Client Object Model is strongly typed and easy to use. If you would like to know more about Managed Client OM, please follow the link: http://www.codeproject.com/Articles/138322/Exploring-SharePoint-2010-Client-Object-Model-Capa

    However, if you would like to stick with REST, then please read the first link below to understand how it works and the second link will provide code sample:


    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com>

    Wednesday, July 31, 2013 1:03 AM
  • Hello All,

    Thanks a lot, I really appreciate the replies you did.

    However here is a bit change in the requirement, here it goes:

    1. I have to create a WCF Rest service(with all steps Hosting and all..) to read data from SQL Server and have to expose it into JSON

    2. Then I have to consume this exposed data into my SharePoint site to perform CRUD operations on lists, list items, files and folders.

    3. I also have to make a client application, so that my client application can call the service and then everything will happen.

    Please let me know how should I achieve this, how should I go step by step to achieve this goal.

    Let me know if there are any links or videos on the same.

    And also let me know that shall I mark above all replies as answered ? 

    Thanks in advance,

    Sushil Sahu


    sushil sahu


    • Edited by sushil sahu Wednesday, July 31, 2013 7:25 AM
    Wednesday, July 31, 2013 7:25 AM
  • Hi All,

    Can anybody please reply on the above post?

    I have to consume the JSON data through AJAX and to perform CRUD Operations on SharePoint lists, files and folders using this JSON data.

    Thanks,

    Sushil


    sushil sahu

    Thursday, August 1, 2013 5:13 AM
  • For now I am following below link

    http://www.codeproject.com/Articles/405189/How-to-access-SQL-database-from-an-iPhone-app-Via

    can anybody please let me know that is it a REST Service? and am I going right?

    Thanks,

    Sushil


    sushil sahu

    Thursday, August 1, 2013 5:18 AM
  • Hello All,

    Waiting for your valuable replies.

    Thanks in advance,

    Sushil


    sushil sahu

    Thursday, August 1, 2013 1:03 PM
  • Here you go:

    1. Create WCF Service Step by Step: http://www.sharepointpals.com/post/Step-by-Step-Procedures-to-create-a-WCF-Service-Application-for-SharePoint-2013. To link shows how to create RESTful service and return data as json. For reading data from sql, you may search on the internet how to read data from sql server.
    2. Again, to update list data using SharePoint, you might get tons of examples on the internet. Basic steps are: open a web, get list, add new list item (or get existing one) and finally update.
    3. For client application, if you want to Managed client object model, you can follow the link: http://msdn.microsoft.com/en-us/library/ee857094%28v=office.14%29.aspx


    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com>

    Friday, August 2, 2013 2:46 AM
  • Thanks a lot Sohel for the nice reply with important links.

    Actually i am done with making RESTful Service, using this service i am reading data from sql server database table and it is returning data when i test the service using Page Inspector in Visual Studio 2012.

    But it is failed to return the data in JSON format, i think somewhere i am getting wrong in the Uri Template property of the WebInvoke Attribute. In the Uri Template property i have given the value as  

    Uri Template="json/employees".

    Once it returns data in json format then my next requirement is to consume this data through AJAX client application and using the same data i have to perform CRUD operations on SharePoint 2013 site lists, files and folders using this client applicaton.

    I think I am done 40%, as I am able to read data from sql table. However please let me know that what i am doing wrong in getting data in Json format?

    Also let me know regarding consuming this json data using Ajax client application and performing CRUD operations on list files and folders using the same data.

    Thanks in advance,

    Sushil 


    sushil sahu


    • Edited by sushil sahu Friday, August 2, 2013 5:14 AM updated contents
    Friday, August 2, 2013 5:13 AM
  • To return data as json you need to specify the request format as 'RequestFormat = WebMessageFormat.Json' in the WebInvoke/WebGet Attribute.

    I'm not sure about Ajax client application(?) but if you want to use javascript/jquery to consume the json data, please follow the link: http://blogs.msdn.com/b/brunoterkaly/archive/2011/11/17/how-to-consume-restful-services-using-jquery-and-or-javascript.aspx


    Thanks,
    Sohel Rana
    http://ranaictiu-technicalblog.blogspot.com>

    Friday, August 2, 2013 6:14 AM
  • Hi Sohel Thanks again,

    Actually i have already specified the request format as 'RequestFormat = WebMessageFormat.Json' in the WebInvoke Attribute, still not getting Data in Json format in the browser.

    Actually i want to test the data returned by the service in the browser and for that purpose i have specified the Uri Template property to Uri Template = "json/employees". Please let me know where i am getting wrong.

    And thanks for the client application link you gave, i will definitely go through it and will try to implement once my above issue get resolved.

    Appriciate your replies.

    Thanks,

    Sushil


    sushil sahu

    Friday, August 2, 2013 6:57 AM
  • Can anybody please reply on this ?

    Thanks in Advance,

    Sushil


    sushil sahu

    Tuesday, August 6, 2013 4:19 AM
  • Hi All thanks for your all the replies,

    I have made a WCF Rest service, it is having 4 methods to read, create, update and delete.

    The service is running for read operation only and returning the data in JSON, I have made this service to read the data from database table so its working however it is not working for create, update and delete methods giving error that "method is not allowed".

    Again I have made a client Ajax call using JQuery for consuming the JSON data returned by the service, however it is giving an error that "It is a Bad Request". When I applied debugger and checked then it is not even going inside the Ajax call.

    Kindly let me know any solutions for above both the issues.

    Thanks in advance,

    Sushil Sahu


    sushil sahu

    Wednesday, August 7, 2013 6:10 AM
  • Hello All,

    My Service is returning JSON data in below format

    { "GetBooksListResult": [ { "BookName": null, "id": 1, "name": "C" }, { "BookName": null, "id": 2, "name": "A" }, { "BookName": null, "id": 3, "name": "B" }, { "BookName": null, "id": 4, "name": "D" }, { "BookName": null, "id": 5, "name": "E" }, { "BookName": null, "id": 6, "name": "F" }, { "BookName": null, "id": 7, "name": "G" } ]}

    When I am consuming this JSON data using Jquery AJAX call then it is giving the below error.

    {

    "GetBooksListResult":[{"BookName":null,"id":1,"name":"C"},{"BookName":null,"id":2,"name":"A"},{"BookName":null,"id":3,"name":"B"},{"BookName":null,"id":4,"name":"D"},{"BookName":null,"id":5,"name":"E"},{"BookName":null,"id":6,"name":"F"},{"BookName":null,"id":7,"name":"G"}]}

    Here the color(:) after GetBooksListResult is highlighted and giving the error that "SCRIPT1004: Expected ';'"

    The data is shown but it is not accepting the above format. Not sure about it.

    Can anyone please let me know how to resolve this issue and the data get consumed.

    Thanks in advance,

    Sushil Sahu


    sushil sahu


    • Edited by sushil sahu Wednesday, August 7, 2013 1:05 PM
    Wednesday, August 7, 2013 1:00 PM
  • Hello All,

    My above issue is resolved but now I am getting "jQuery17109705336543813539_1375884810440 was not called" error.

    I searched a lot on this but not getting anything.

    Please let me know any solution on this.

    Thanks in advance,

    Sushil Sahu


    sushil sahu

    Wednesday, August 7, 2013 2:15 PM
  • Hi All,

    Above issue is resolved and now I am able to consume the JSON data.

    My next task is to perform CRUD operations on SharePoint 2013 lists, files and folders.

    If you have any link or Steps on this then please let me know.

    Thanks in advance,

    Sushil Sahu


    sushil sahu

    Thursday, August 8, 2013 6:38 AM
  • Hi Sushil

    Please find below the link to a useful article with nice REST samples for CRUD operations.

    http://www.plusconsulting.com/blog/2013/05/crud-on-list-items-using-rest-services-jquery/

    Narahari


    ******If a post answers/helps your question, please click "Mark As Answer" on that post and/or "Vote as Helpful*******

    • Marked as answer by sushil sahu Monday, August 12, 2013 5:52 AM
    • Unmarked as answer by sushil sahu Monday, August 19, 2013 6:02 AM
    • Marked as answer by sushil sahu Monday, August 19, 2013 6:10 AM
    Thursday, August 8, 2013 6:44 AM
  • Hello All,

    Thanks a lot I completed the above task, able to perform CRUD on SharePoint 2013 lists.

    Thanks again,

    Sushil Sahu


    sushil sahu

    Monday, August 12, 2013 5:52 AM
  • I followed the below link:

    http://adicodes.com/add-update-and-delete-list-items-using-ecmascript/

    Thanks,

    Sushil


    sushil sahu

    • Edited by sushil sahu Monday, August 19, 2013 6:10 AM
    • Marked as answer by sushil sahu Monday, August 19, 2013 6:10 AM
    Monday, August 12, 2013 5:53 AM