Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Authentication Failed while executing query expression using organizationservice in console app, connection was successfully established

Posted on by 15

Hello Everyone,

Am trying to write Console Application using C# to connect to CRM system

String url = "">company.crm.dynamics.com/.../Organization.svc";
try
{
ClientCredentials clientCredentials = new ClientCredentials();
clientCredentials.UserName.UserName = "company@company.com;
clientCredentials.UserName.Password = "CompanyPassword";

// For Dynamics 365 Customer Engagement V9.X, set Security Protocol as TLS12
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

organizationService = (IOrganizationService)new OrganizationServiceProxy(new Uri(url), null, clientCredentials, null);

if (organizationService != null)
{

 QueryExpression querExp1 = new QueryExpression()
                                    {
                                        EntityName = "EntityName",
                                        ColumnSet = new ColumnSet("Col1", "Col2")

                                    };
                                    querExp.Criteria.AddCondition("name", ConditionOperator.Equal, value1);


                                    EntityCollection EntityList= organizationService.RetrieveMultiple(querExp); ------Error Throw

}

If i try using the above code am getting "An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail."

if i see FaultException i can see "Authenticate Failure" Error

If i try using the same username and password i can able to Access the CRM System( USING AUTHENTICATION app)

  • RE: Authentication Failed while executing query expression using organizationservice in console app, connection was successfully established

    Any Help

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans