2017-03-22 6 views
0

私は以下のコードを使用して、msダイナミクスcrmからアカウントをロードしようとしています。 私はでき..500内部サーバエラーMs dynamics CRMをadalを使用してjava

Access Token - xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
UserId - xxxxxxxxxxxxxxxxxxxxxxxxxxxx 
res code : 500 
Exception in thread "main" java.io.IOException: Server returned HTTP 
response code: 500 for URL: https://paperflite1.api.crm8.dynamics.com/api/data/v8.0/accounts?$select=name&$top=1 
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) 
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) 
at java.lang.reflect.Constructor.newInstance(Unknown Source) 
at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source) 
at sun.net.www.protocol.http.HttpURLConnection$10.run(Unknown Source) 
at java.security.AccessController.doPrivileged(Native Method) 
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(Unknown Source) 
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source) 
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) 
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Unknown Source) 
at PublicClient.loadAccounts(PublicClient.java:104) 
at PublicClient.main(PublicClient.java:53) 
Caused by: java.io.IOException: Server returned HTTP response code: 500 for URL: https://paperflite1.api.crm8.dynamics.com/api/data/v8.0/accounts?$select=name&$top=1 
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source) 
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) 
at java.net.HttpURLConnection.getResponseCode(Unknown Source) 
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(Unknown Source) 
at PublicClient.loadAccounts(PublicClient.java:99) 
... 1 more 

私はダイナミクスCRM

private static String loadAccounts(String token, String userId) throws MalformedURLException, IOException { 
    HttpURLConnection connection = null; 
    URL url = new URL(RESOURCE + "/api/data/v8.0/accounts?$select=name&$top=1"); 
    connection = (HttpURLConnection) url.openConnection(); 
    connection.setRequestMethod("GET"); 
    connection.setRequestProperty("Authorization", "Bearer " + token); 
    connection.setRequestProperty("Content-Type", "application/json; charset=utf-8"); 
    connection.setRequestProperty("OData-MaxVersion", "4.0"); 
    connection.addRequestProperty("OData-Version", "4.0"); 


    int responseCode = connection.getResponseCode(); 
    System.out.println("res code : "+ responseCode); 


    BufferedReader in = new BufferedReader(
      new InputStreamReader(connection.getInputStream())); 
    String inputLine; 
    StringBuffer response = new StringBuffer(); 

    while ((inputLine = in.readLine()) != null) { 
     response.append(inputLine); 
    } 
    in.close(); 

からアカウントをロードするために使用していますが、私は次の例外を取得していますコード

private static AuthenticationResult getAccessTokenFromUserCredentials() throws Exception { 
    AuthenticationContext context = null; 
    AuthenticationResult result = null; 
    ExecutorService service = null; 
    try { 
     service = Executors.newFixedThreadPool(1); 
     context = new AuthenticationContext(AUTHORITY, false, service); 
     /* 
     * Replace {client_id} with ApplicationID and {password} with 
     * password that were used to create Service Principal above. 
     */ 
     ClientCredential credential = new ClientCredential("xxxxxxxxxxxxxxxxxxxx", 
       "xxxxxxxxxxxxxxxxxxxxxxxxx="); 
     Future<AuthenticationResult> future = context.acquireToken("https://xxxxxxxxxx.api.crm8.dynamics.com", 
       credential, null); 
     result = future.get(); 
    } finally { 
     service.shutdown(); 
    } 
    if (result == null) { 
     throw new ServiceUnavailableException("authentication result was null"); 
    } 
    return result; 
} 

コードを使用することによってaccesstokenましたいずれかの助けてください..

答えて

0

あなたのWebに間違ったURLを使用しているようですAPI呼び出し。それは https://paperflite1.crm.dynamics.com/api/data/v8.0/accounts?$select=name&$top=1でなければなりません。あなたのCRM組織のURLと仮定してください。

関連する問題