jeudi 11 décembre 2014

How do I access a Custom List from a client web part via the REST API?



I am using the following code to try and access my newly created Custom List called Announcements:



$.ajax({
url: appWebUrl + "/_api/web/lists/getbytitle('Announcements')/items",
method: "GET",
headers: { "Accept": "application/json; odata=verbose" },
success: function (data) {
list = data;
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
debugger;
alert("Error! " + errorThrown);
}
});


The debugger gets invoked in my error handler, showing a 404 result, and when I paste the url into a browser, I get the following xml message:



<m:error xmlns:m="http://ift.tt/1dtZymv">
<m:code>-1, System.ArgumentException</m:code>
<m:message xml:lang="en-US">
List 'Announcements' does not exist at site with URL 'http://ift.tt/1yDko8a'.
</m:message>
</m:error>


This tells me I am reaching my site, but it doesn't seem to know it has the list. The only way I can find to create a list in SP online is with the Custom List app. What am I missing?








0 commentaires:

Enregistrer un commentaire