0
我正在使用Watson對話。我得到當試圖執行一個ServiceCall,在ResponseUtils的90線的異常(在的getObject):Watson對話:無法執行ServiceCall
final T model = GsonSingleton.getGsonWithoutPrettyPrinting().fromJson(reader, type);
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected a string but was BEGIN_ARRAY at line 1 column 647 path $.output.text
我探索響應和我看到: 響應{協議= HTTP/1.1,代碼= 200,消息= OK,URL = https://gateway.watsonplatform.net/conversation-experimental/api/v1/workspaces/200afa7d-c71f-472a-ab6e-5bf162f6e319/message?version=2016-05-19}
這是我的代碼:
import com.ibm.watson.developer_cloud.conversation.v1_experimental.ConversationService;
import com.ibm.watson.developer_cloud.conversation.v1_experimental.model.Message;
import com.ibm.watson.developer_cloud.conversation.v1_experimental.model.NewMessageOptions;
import com.ibm.watson.developer_cloud.conversation.v1_experimental.model.NewMessageOptions.Builder;
import com.ibm.watson.developer_cloud.http.ServiceCall;
public class TestConversation {
public static void main(String[] args) throws Exception{
ConversationService service = new ConversationService(ConversationService.VERSION_DATE_2016_05_19);
service.setEndPoint("https://gateway.watsonplatform.net/conversation-experimental/api");
service.setUsernameAndPassword("xxxxxxxx", "xxxxxx");
Builder builder = new NewMessageOptions.Builder().workspaceId("xxxxxxxxxxxx");
NewMessageOptions newMessageOptions = builder.inputText("hi").build();
ServiceCall<Message> serviceCall = service.message(newMessageOptions);
Message answer = serviceCall.execute();
}
}