Reputation: 31
I'm currently learning Extending Microsoft Dynamics CRM Online and On Premise Course provided by Microsoft.
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;
[email protected];
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".
What else could cause this error?
Thank You.
Upvotes: 3
Views: 5150
Reputation: 5715
The error "An unsecured or incorrectly secured fault was received from the other party" usually means that the password is incorrect, but it can also occur if the time between the application and the CRM server is more than 5 minutes apart. I have seen this happen when an application is deployed to a virtual server and the VM experiences "time drift" - it might work at some point, but the VM may slowly get out of sync with internet time and then run into issues authenticating.
From this forum thread
Upvotes: 0
Reputation: 486
Hopefully this helps someone else, I was fighting with this same error for a good while today as well.
Turns out I was using an older version of the Microsoft.CrmSdk.CoreAssemblies nuget package(7.1.1 in one project and 8.0.0 in another) as soon as I updated it to the latest (8.2.0.2) I was able to successfully connect to CRM Online.
Upvotes: 3