0

enter image description here 我正在從Android Studio進行API調用。沒有錯誤,但是當我在亞行運行時,我的應用程序停止說「不幸的是,該應用程序已停止」任何人都可以看到並告訴我做錯了什麼?非常感謝Watson API調用失敗

回答

0

你必須爲你的應用程序設置工作區ID,你明白嗎?

例子:

ConversationService service = new ConversationService("08-11-2016"); 
service.setUsernameAndPassword("{username}", "{password}"); 

MessageRequest newMessage = new MessageRequest.Builder() 
    .inputText("Turn on the lights") 
    // Replace with the context obtained from the initial request 
    //.context(...) 
    .build(); 

String **workspaceId** = "**ID from your conversation...**"; 

MessageResponse response = service 
    .message(workspaceId, newMessage) 
    .execute(); 

System.out.println(response); 
+0

我做了包括工作區ID,它沒有工作。 –

+0

謝謝@Sayuri,我嘗試了你的代碼方式,它的apk應用程序在我的手機上以及通過ADB運行時崩潰。 –