A.K
A.K

Reputation: 505

Unable to connect via connection string to Dynamics CRM Online. Organization cannot be null or empty. Parameter name: Organization Name

I'm trying to connect to CRM Online via connection string using Microsoft.CrmSdk.XrmTooling.CoreAssembly v 8.2.0.5

Following the guidelines at MSDN my connection string looks like this: AuthType=Office365;[email protected]; Password=passcode;Url=https://contoso.crm.dynamics.com

However, I get error an exception of type System.ArgumentNullException with Message: Organization cannot be null or empty. Parameter name: Organization Name

Source: Microsoft.Xrm.Tooling.Connector

public void GetClient()
{
    try
        {
            var client = new CrmServiceClient(GetConnectionString());
            Assert.IsTrue(client.IsReady);

        }
        catch (Exception ex)
        {
            throw;
        }

}
private string GetConnectionString()
{
    try
    {
        var connectionString = default(string);

        try
        {
            connectionString = "AuthType:Office365;Url=https://MyCRM.crm4.dynamics.com; [email protected];Password=MySecretPasscode;"; 
        }
        catch (Exception ex)
        {
            throw;
        }
        return connectionString;
    }
    finally
    {

    }
}

Upvotes: 0

Views: 3386

Answers (3)

user1921169
user1921169

Reputation: 1

you still need to put the org name at the end of the url so it should be someting like this:Url=https://contoso.crm.dynamics.com/contoso;

Upvotes: -1

Pawel Gradecki
Pawel Gradecki

Reputation: 3586

The problem is here:

"AuthType:Office365; ..."

This should be:

"AuthType=Office365; ..."

Upvotes: 4

Javier Jimenez Matilla
Javier Jimenez Matilla

Reputation: 312

you have to write the connectionstring like this:

 <add name="Server=CRM Online, 
organization=contoso, user=someone"
connectionString="Url=https://contoso.crm.dynamics.com;
[email protected]; Password=password; authtype=Office365"/> -->

sample to-do

Hope this help!

Upvotes: 0

Related Questions