0

I've just started with SharePoint, I've set up a website and now i'm wondering, how i can communicate with a REST Web Service with Sharepoint. What's best practice in this case?

0

For example it is easy to use Jquery to communicate with the web service:

// Getting list items based on ODATA Query
function getListItems(url, listname, query, complete, failure) {

    // Executing our items via an ajax request
    $.ajax({
        url: url + "/_api/web/lists/getbytitle('" + listname + "')/items" + query,
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
            complete(data); // Returns JSON collection
        },
        error: function (data) {
            failure(data);
        }
    });

}

Please also read the 'Get to know the SharePoint 2013 REST service' article from Microsoft for all possibilities.

|improve this answer|||||
  • Can i define this function directly in a webpart or should this be in another file? – PrototypeX7 Feb 18 '16 at 10:03
  • @PrototypeX7 it is possible to do this within a webpart. – Citizen SP Feb 18 '16 at 10:30
1

The goal of this

http://www.codeproject.com/Articles/990131/CRUD-Operation-to-List-Using-SharePoint-Rest-API

is to provide a complete idea about CRUD (create, read, update and delete) operation in a list of SharePoint 2013 using REST API.

Good Practices and all basic operations are covered in this link.

To perform Rest Calls you may need to add JQuery Reference on the Page as well.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.