如何通过 Java 连接 Azure Cloud 上的 Dynamics CRM 2016 实例 运行?

How to connect Dynamics CRM 2016 instance running on Azure Cloud through Java?

你可以这样做。 Dynamics 公开了 REST API 供使用,而这个 API 与任何一个都没有什么不同。

Here 您可以找到有关 API 的所有详细信息。

我刚刚在 Google 上搜索了一下,发现 article 通过 REST

连接到 Dynamics crm(在线)很不错

正如@ankuser 正确建议的那样,通过 Dynamics CRM api 可以查询很多资源。需要记住的重要一点是,Microsoft 为 Java 提供了 ADAL Azure Active Directory 身份验证库,以帮助您使用不记名令牌。

你需要它来调用动态的不记名令牌api:

这是获取令牌的示例代码:

private final static String CLIENT_ID = "00000000-0000-0000-0000-000000000000";
//CRM URL
private final static String RESOURCE = "https://org.crm.dynamics.com";
//O365 credentials for authentication w/o login prompt
private final static String USERNAME = "administrator@org.onmicrosoft.com";
private final static String PASSWORD = "password";
//Azure Directory OAUTH 2.0 AUTHORIZATION ENDPOINT
private final static String AUTHORITY = 
    "https://login.microsoftonline.com/00000000-0000-0000-0000-000000000000";

AuthenticationContext context = null;
AuthenticationResult result = null;
ExecutorService service = null;
try {
    service = Executors.newFixedThreadPool(1);
    context = new AuthenticationContext(AUTHORITY, false, service);
    Future<AuthenticationResult> future = context.acquireToken(RESOURCE,
            CLIENT_ID,
            USERNAME,
            PASSWORD, null);
    result = future.get();
} finally {
    service.shutdown();
}

String token = result.getAccessToken();

额外参考,您可以浏览下面的代码库:

https://github.com/jlattimer/CrmWebApiJava

详细步骤指南请参考:

https://www.fmtconsultants.com/connect-java-application-crm-simple-java-console-application/

希望对您有所帮助。