0
votes

I am trying to access the items under a list in a subsite of sharepoint site collection using REST API.

To access the items of a list in a site we use: https://Server/Site/_api/web/lists/getbytitle('myList')/items (it works)

But if I try to use the same for a subsite it doesn't work: https://Server/Site/SubSite/_api/web/lists/getbytitle('myList')/items

Any idea on how to achieve this?

I have gone through the documentation here http://msdn.microsoft.com/en-us/library/fp142385.aspx, but it doesn't give any info on subsites. Postman ERROR

2

2 Answers

0
votes

Warrior,

I tested it on my SPO environment. It could get items from a subsite.

enter image description here

So could you please have a check if the url is correct and the list is in the subsite? And what about the error msg?

BR

0
votes

You need to get current url site _spPageContextInfo.webAbsoluteUrl

Try this:

var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('myList')/items"

or write url

  1. http://sp
  2. http://sp/sites/test
  3. http://sp/sites/test/avi