Sharepoint hosted app REST call to list items shows Access denied. You do not have permission to perform this action or access this resource

sharepoint.stackexchange https://sharepoint.stackexchange.com/questions/194010

Domanda

Following code in app giving exception "Access denied. You do not have permission to perform this action or access this resource". Even I have allowed permission "APP > MANAGE PERMISSION > TRUST IT".

$.ajax({
method: "GET",
url: hostweburl+"/_api/web/lists/getByTitle('Waqarreading')/items",
headers:{
 "accept":"application/json;odata=verbose"
}
}).done(function(data) {
   console.log("list-data ==== ", data);
}).fail(function() {
   console.log("list-data Fail ");
}).always(function() {
                console.log( "list-data Completed!" );
              });

Request sent at: https://waqarmuneer.sharepoint.com/_api/web/lists/getByTitle('Waqarreading')/items

È stato utile?

Soluzione

Last time I encountered such issue, I had to use cross-domain library as per following article:

https://msdn.microsoft.com/en-us/library/office/fp179927.aspx

as it states the following:

When a user requests a page from your add-in domain (1), the client-side communication is bound only to that domain. Your add-in can issue client-side calls from the page only to other resources in the same domain. However, add-ins usually require resources from other domains, such as the SharePoint domain, to fulfill their scenarios. In the code in your page, you may try to issue a request to the SharePoint domain (2), which is blocked by the browser. You usually see an Access is denied error. The error doesn’t imply that you don’t have permissions to the requested resources but, most likely, you can’t even issue a request to the mentioned resources.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top