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)

An unsecured or incorrectly secured fault was received from the other party

(0) ShareShare
ReportReport
Posted on by 1,214

Hi. I'm currently learning Extending Microsoft Dynamics CRM Online and On Premise Course Module 5 Using the Organization Service.

I'm simply following the steps according to this lab documentation. The code should be perfectly working but it doesn't work for me.

Connection Strings:

<connectionStrings>
<add name="CRMOnline"
     connectionString=
                 "Url=https://xxxxxx.api.crm5.dynamics.com/XRMServices/2011/Organization.svc;   
                 Username=xxxxxx@damnits.onmicrosoft.com; 
                 Password=xxxxxx;"/>
</connectionStrings>

The connection :

CrmConnection con = new CrmConnection("CRMOnline");

        IOrganizationService service = new OrganizationService(con);

        WhoAmIRequest req = new WhoAmIRequest();

        var result = service.Execute(req) as WhoAmIResponse;

        if (result != null)
        {
            Console.WriteLine(String.Format("Organization ID: {0}\nBusiness Unit ID: {1}\nuser ID:{2}", result.OrganizationId, result.BusinessUnitId, result.UserId));
            Console.ReadLine();
        } 

The exception is caught in this line : var result = service.Execute(req) as WhoAmIResponse; Innerexception said "Invalid Request".

  • I have made sure the credentials on connectionStrings are correct multiple times
  • I think I have already synchronized the date & time for my pc and the CRM (synchronized internet time & selected the correct time zone on both PC & CRM. Even tested created a record & checked date&time created is correct.)

What else could cause this error?

Thank You.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at
  • HAIRUL HAZRI Profile Picture
    1,214 on at

    Hi Nithya.

    The link is pretty useful and contains a lot of good info but I'm still unable to pinpoint which part is wrong with the code or configurations. I guess those examples are a little bit too complex for me.

    Thanks & Regards

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Hairul Hazri,

    Can you change the URL as shown below.

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    Hi Nithya,

    this is Organization Service URL right? Already did, and I've updated the post as well. But still same result.

    Thanks & Regards.

  • Suggested answer
    Nithya Gopinath Profile Picture
    17,078 on at

    No, I think that '.api' in the URL is not required.

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    Tried removing the .api also. Still not working.

  • Nithya Gopinath Profile Picture
    17,078 on at

    What are you really trying to do using the code? Is it just the connection part?

  • HAIRUL HAZRI Profile Picture
    1,214 on at

    Yes. Just connection part and to display the organization id, business unit id, & user id to prove that the connection is working.

    I provided the lab documentation I'm working with on the hyperlink "this" above  just in case, if you haven't notice that.

    The lab is provided by microsoft as reference material for the course Extending CRM.

  • Verified answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi Hairul Hazari,

    Please try the code in the following blog instead of your code for connection.

    arunpotti.wordpress.com/.../connect-to-crm-online-or-on-premise-using-c

    It is an easy method to connect crm online via crm sdk.

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi HAIRUL

        I think the url should be https://your server url/your organzation; So try remove thing after your server name such begin from XRMService and add the organzation name if you have.

        Also in the link you post, it only use the server url in the connection string.

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