0
votes

I have created a site in ms sharepoint and in the documents created a word doc. I want to access all the documents in the 'Documents' location using REST API.

I created the application to generate app id and secret using: https://apps.dev.microsoft.com/#/application

Then i generated an access token using: https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=XXX&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fmyapp%2F&response_mode=query&scope=openid%20offline_access%20https%3A%2F%2Fgraph.microsoft.com%2FSites.ReadWrite.All&state=12345

The scope I used is Sites.ReadWrite.All based on https://docs.microsoft.com/en-us/onedrive/developer/rest-api/concepts/permissions_reference?view=odsp-graph-online

After i got the access token I am making a REST call as follows:

https://4development106.sharepoint.com/<mysite name>/_api/web/GetFolderByServerRelativeUrl('/Shared Documents')

accept: application/json;odata=verbose
Authorization: "Bearer" + "my access token"

But i get a 404.

I do have a document created in the site under documents. Please advise

1
try it as https://4development106.sharepoint.com/<mysite name>/_api/web/GetFolderByServerRelativeUrl('/<mysite name>/Shared Documents') and check Gautam Sheth
thanks no luck though :(Vik

1 Answers

1
votes

this is how I access a Sharepoint site to get the known list. I think you'll need the same initial url structure:

https://my.sharepoint.com/sites/oh/_api/web/lists/getbytitle('#{list_title}')

i.e. there's an intial sites path segment before the site name, in this case the name of the site is oh

so you could try:

https://4development106.sharepoint.com/sites/<mysite name>/_api/web/GetFolderByServerRelativeUrl('/Shared Documents')