即使在CRM动态中使用了正确的凭据也无法连接到组织服务-C# [英] Not able to connect to Organization service even with used correct credentials in CRM dynamics - C#

查看:74
本文介绍了即使在CRM动态中使用了正确的凭据也无法连接到组织服务-C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使我在CRM动态中使用了正确的凭据,我也无法连接到组织服务-C#我可以使用相同的凭据从dynamics crm网站登录.我正在使用Microsoft.crm.SDK版本9,并且还通过HttpClient获得了响应代码200,如下所示.

 使用(var client = new HttpClient()){client.BaseAddress =新的Uri(webApiUrl);client.DefaultRequestHeaders.Authorization = authHeader;var response = client.GetAsync("WhoAmI").Result;} 

但是问题出在组织服务上,这给了我消息安全异常.您能帮我这个忙吗,我已经尝试了许多来自互联网的解决方案,但没有成功.请查找附件中的照片以获取例外的详细信息,如果需要更多信息,请随时查看.

我正在使用的连接字符串

组织服务错误

内部异常

解决方案

如果我正确理解您的问题,则说明您正在在线使用Dynamics 365 9.0版,并且正在使用webapi连接到Dynamics.

您在这里有点困惑.使用c#有两种方法可以连接到crm.1.使用webapi.在这里,您需要身份验证令牌,等等.2. Dynamics 365(crm程序集)在这里,您不需要身份验证令牌,而需要用户名和密码

并且您想要webapi,因此在您的情况下不需要组织服务,一旦您连接了身份验证标头等等,就可以调用webapi url进行创建/检索等等,以完成工作.

一些关于webapi的示例

https://www.inogic.com/blog/2016/04/set-values-of-all-data-types-using-web-api-in-dynamics-crm-通过-c/

https://docs.microsoft.com/zh-CN/powerapps/developer/common-data-service/webapi/web-api-samples-csharp

https://rajeevpentyala.com/tag/web-api/

使用控制台应用程序的组织服务示例

我不确定您将在哪里触发c#,但下面的控制台应用程序示例将为您提供帮助

https://www.google.com/amp/s/arunpotti.wordpress.com/2018/02/03/逐步使用C-console-application/amp/

连接动力学365-crm-online-v9-x

您也可以从XRMToolBox插入插件.它称为 codenow 这肯定会解决您的问题.

I am not able to connect to Organization service even with I have used correct credentials in CRM dynamics - C# I am able to login from dynamics crm site with same credential. I am using Microsoft.crm.SDK version 9 and also getting response code 200 with HttpClient as shown below.

 using (var client = new HttpClient())
 {
          client.BaseAddress = new Uri(webApiUrl);
          client.DefaultRequestHeaders.Authorization = authHeader;
          var response = client.GetAsync("WhoAmI").Result;
 }

BUT the problem is with Organization service, It is giving me message security exception. Can you please help me with this, I have tried many solutions from internet but not succeed. Please find attached photos for exception detail, and feel free if you need more information.

Connection string I am using

Error from organization service

Inner exception

解决方案

If I understand your question correct, you are using dynamics 365 version 9.0 online and you are connecting to dynamics using webapi.

You are bit confused here. There are 2 ways from using c# you can connect to crm. 1. Using webapi. Here you need authentication token and so on. 2. Dynamics 365 (crm assemblies) here you do not need authentication token rather username and password

And you want webapi so in your case no need for organizationservice, once you are connected with your authentication header and so on you can call webapi url for create/retrieve and so on and get your work done.

Some examples here for webapi

https://www.inogic.com/blog/2016/04/set-values-of-all-data-types-using-web-api-in-dynamics-crm-through-c/

https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/webapi/web-api-samples-csharp

https://rajeevpentyala.com/tag/web-api/

Using organization service example of console app

I am not sure where you will be firing your c# but below example of console app will help you

https://www.google.com/amp/s/arunpotti.wordpress.com/2018/02/03/step-by-step-to-connect-dynamics-365-crm-online-v9-x-using-c-console-application/amp/

Edit:

You could also you plugin from XRMToolBox. It is called codenow This will definitely solve your issue.

这篇关于即使在CRM动态中使用了正确的凭据也无法连接到组织服务-C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆