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)

Create Folder in SharePoint from CRM Online Plugin failing

(2) ShareShare
ReportReport
Posted on by 55,410 Moderator

Hi All,

I have used the below code sample to integrate SharePoint & CRM Online for creating folder in SharePoint. This was working fine but since this week, it has started throwing bad request error while creating the authentication cookies.

https://code.msdn.microsoft.com/SharePoint-Integration-c5f21604/sourcecode?fileId=131706&pathId=1614921635

http://develop1.net/public/post/SharePoint-Integration-Reloaded-e28093-Part-3.aspx

Would appreciate any help fix this issue.

*This post is locked for comments

I have the same question (0)
  • RaviKashyap Profile Picture
    55,410 Moderator on at

    *Bump*

  • David Jennaway Profile Picture
    14,065 on at

    From the code, it looks like the call to get the authentication cookies is for the web service calls to SharePoint, so the issue is more likely to lie with changes to SharePoint, rather than within CRM. I suggest posting the question to a SharePoint forum to see if anyone can help there

  • Andreas Cieslik Profile Picture
    9,267 on at

    I would try to create a console application with the code sample and try to debug and find out the exact issue.

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Thanks Andreas.

    I also tried to debug it using console app and it was failing [Bad Request] while calling  "SpoAuthUtility.Create"

    I have also noticed that while login to online service [CRM, SharePoint etc], we are getting this new popup asking to try new sign in experience. Not sure if this could be related ti this.

    Looking forward for your response.

    signin.png

  • Verified answer
    Andreas Cieslik Profile Picture
    9,267 on at

    I tested myself the "SpoAuthUtility.Create".

    I had to change the following (red) to make it work:

            public static byte[] SendHttpRequest(Uri uri, String method, byte[] requestContent = null, string contentType = null, HttpWebRequest clientHandler = null, Dictionary<string, string> headers = null)
            {
                HttpWebRequest request = clientHandler == null ?  (HttpWebRequest)HttpWebRequest.Create(uri): clientHandler;

                byte[] responseStream;


                request.Method = method;
                request.Accept = "application/json, text/javascript, */*; q=0.01";

  • Community Member Profile Picture
    on at

    Hi Ravi,

    we are currently facing a similar issue. The SpoAuthUtility suddenly doesnt work anymore. The issue seems to be in the method "private Uri GetAdfsAuthUrl()"

    private Uri GetAdfsAuthUrl() 
            { 
                Uri corpAdfsProxyUrl = null; 
     
                Uri msoHrdUri = new Uri(msoHrdUrl); 
                HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(msoHrdUri); 
                // make a post request with the user's login name to  
                // MSO HRD (Home Realm Discovery) service so it can find  
                // out the url of the federation service (corporate ADFS)  
                // responsible for authenticating the user 
     
                byte[] response = HttpHelper.SendHttpRequest( 
                     new Uri(msoHrdUrl), 
                     "POST", 
                     Encoding.UTF8.GetBytes(String.Format("handler=1&login={0}", this.username)), // pass in the login name in the body of the form 
                     "application/x-www-form-urlencoded", 
                     request); 
                //The Response is null. If you convert it to an XML request you get a response, but it doesnt contain the AuthURL field 
    STSInfo info = Deserialize<STSInfo>(response); if (info != null && !String.IsNullOrEmpty(info.AuthURL)) { corpAdfsProxyUrl = new Uri(info.AuthURL); } return corpAdfsProxyUrl; }


    Unfortunately we didnt find a solution yet ... 

  • Community Member Profile Picture
    on at

    Hi Andreas,

    i tried your solution and the SendHTTPRequest works again. But the issue i mentioned in my other post (missing AuthURL Attribute in response) still exists.

  • Suggested answer
    Andreas Cieslik Profile Picture
    9,267 on at

    In my example I directly connect to Dynamics 365 Online and SharePoint Online, which always has AuthURL equals to null. I do not have any Federated Authentication which could be the reason why it behaves a little different.

    If the SharePoint Online instance uses federated authentication, the response from Microsoft Online can contain up to two authentication endpoints that can be used by the connector to authenticate with SharePoint Online. These are at the following locations in the XML response:

    /RealmInfo/AuthURL - This endpoint is used by default by this tool and  uses https://AuthURL host/adfs/services/trust/2005/usernamemixed/ as the ADFS proxy to authenticate with SharePoint Online.

    /RealmInfo/STSAuthURL - To use this endpoint as the ADFS proxy to authenticate with SharePoint Online, set this parameter to true. Use this option when the default endpoint is not available.

    A common indicator that this parameter needs to be set is the following error appearing: “Sign in failed using corporate credentials: The remote server returned an error: (404) Not Found”.

    Maybe Microsoft has currently an issue with Federations or something with Federation settings got messed up?

  • Andreas Cieslik Profile Picture
    9,267 on at

    In addition this page shows the possible responses with or without federation configured:

    blogs.technet.microsoft.com/.../cloud-tip-of-the-day-advanced-way-to-check-domain-availability-for-office-365-and-azure

    So I guess you might have an issue with your Federations settings or as I already mentioned MS has an internal issue or changed global behavior.

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Thank you so much for your help Andreas. It worked for me.

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