Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Call SharePoint REST API from Dynamics CRM Online

Posted on by Microsoft Employee

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

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Call SharePoint REST API from Dynamics CRM Online

    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.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Call SharePoint REST API from Dynamics CRM Online

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

  • sandeepstw Profile Picture
    sandeepstw 4,601 on at
    RE: Call SharePoint REST API from Dynamics CRM Online

    Hi,

    Please check this link:

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

    Thanks,

    Sandeep

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans