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运行时崩溃。 –