web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Call SharePoint REST API from Dynamics CRM Online

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • sandeepstw Profile Picture
    4,601 on at

    Hi,

    Please check this link:

    sharepoint.stackexchange.com/.../how-to-use-the-fedauth-cookie-in-clientcontext

    Thanks,

    Sandeep

  • Community Member Profile Picture
    on at

    Thanks, but I'm looking solution for REST API in JavaScript

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans