0

We have Intranet in our organization in which we have one list called announcement which also consist one custom column. Now I want to read that list data using rest api for mobile app of our organization.

while i am trying to read, I am getting exception.Should I need to pass login credential with Rest API? If yes, than How can I pass it?

  • can you please add more detail about which mobile app you are creating? window mobile app? – Aakash Maurya May 2 '16 at 9:00
  • we will use it in Every mobile platform – akj May 2 '16 at 9:02
  • you are going to use C# as a back end code? or you can post some of the code detail which you are using and what kind of exception you are getting? – Aakash Maurya May 2 '16 at 9:03
  • the exact exception would be helpful – Gwny May 2 '16 at 9:17
  • Url : test:2525/_api/Web/Lists/GetByTitle('Test')/items Exception: This XML file does not appear to have any style information associated with it. The document tree is shown below. <m:error xmlns:m="schemas.microsoft.com/ado/2007/08/dataservices/metadata"> <m:code>-1, System.Reflection.TargetInvocationException</m:code> <m:message xml:lang="en-US"> Exception has been thrown by the target of an invocation. </m:message> </m:error> – akj May 2 '16 at 9:24
1

If you are developing a mobile app which will communicate with your SharePoint 2013 then you can use the common services that can be accessed using open protocols.

If your REST Service API codes are hosted in your SharePoint environment then in that case you do not need any authentication mechanism.

But if your code is hosted somewhere else other than SharePoint environment then you need to first authenticate your REST Service API calls.

And for Authenticating your REST Service API calls and perform operations using it in SharePoint site you can find an article Build mobile apps for other platforms using SharePoint 2013

The following code demonstrates how to authenticate your app to SharePoint 2013 using REST endpoints for basic or forms-based authentication. The following code example is written in C#, but any other programming language can be used to create the HTTP request, as per the requirement of the platform.

The above line in article explains how to use authentication mechanism using C# calls or any other language call and it also contains codes for performing operations using REST Service API

0

You do not need to pass the credentials. Please look into below mentioned code to get single item from list using REST API.

function getListItem(url, listname, id, complete, failure) {
    // Getting our list items
    $.ajax({
        url: url + "/_api/web/lists/getbytitle('" + listname + "')/items(" + id + ")",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
            // Returning the results
            complete(data);
        },
        error: function (data) {
            failure(data);
        }
        });
    }
}

Note :- Here you need to change the list name & item id

You can find all CRUD operations for list from this link

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.