Hello!
Trying to call SharePoint Online REST API from Dynamics CRM Resource (js file).
This is the code:
function spOnLoad() { var req = new XMLHttpRequest(); req.withCredentials = true; req.open("GET", encodeURI("<sp url>/_api/lists/getbytitle('Documents')/items"), true); req.setRequestHeader("Accept", "application/json;odata=verbose"); req.onreadystatechange = function () { if (this.readyState == 4 /* complete */) { debugger; req.onreadystatechange = null; } }; req.send(); }
But every time I get 403 forbidden. When I check Fiddler I see that "FedAuth=" cookie provided.
Any suggestions?
*This post is locked for comments
You need to pass the Authorization Header in your script with the SharePoint Token (followed by Bearer: keyword).
Please refer to the following blog on how to get that:
spshell.blogspot.com/.../sharepoint-online-o365-oauth.html
Hope this helps.
Thanks, but I'm looking solution for REST API in JavaScript
Hi,
Please check this link:
sharepoint.stackexchange.com/.../how-to-use-the-fedauth-cookie-in-clientcontext
Thanks,
Sandeep
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156