Online Dynamics CRM 2015 web service call error IdentityProvider cannot be null

294 views Asked by At

I've just started on CRM and ran into some trouble with calling the Organization service. I've read that for online CRM that I need to get the device ID and password and pass that in the method. This is done by calling the HelperCode in the SDK "DeviceIdManager".

All I wanted to do was simply connect to the service and then I'd do what I needed to do (e.g. retrieve account information).

To keep it simple I did (not real username and password):

  Uri orgUri = new Uri("https://xxx.api.crm.dynamics.com/XRMServices/2011/Organization.svc");

  ClientCredentials cc = new ClientCredentials();
  cc.UserName.UserName = "[email protected]";
  cc.UserName.Password = "abc123";

  //GetDeviceCredentials is from the SDK helper class
  OrganizationServiceProxy orgProxy = new OrganizationServiceProxy(orgUri, null, cc, GetDeviceCredentials());
  orgProxy.Authenticate();

This is the error on the Authenticate():

enter image description here

I searched around and it seems that I've followed the general idea of what others have done.

Any suggestions on how I can get it to authenticate properly so i can query the account entity would be great.

I've done something similar using the Discover Service and that works (without the Device Credentials) so I'm a bit perplexed of what I've done wrong here.

Thanks for your time.

1

There are 1 answers

0
Mike Stone On

I feel like a brick.

I should have paid more attention to the MSDN.

The call should have been "LoadOrRegisterDevice" instead of GetDeviceCredentials.