网址为:http://xx.xx.xx.xx:9080/myprocess?action=start¶ms= {\“inputName \”:\“Test \”}
在上面的网址中,我的JSON字符串是{\“inputName \”:\“omsai \”}
我按以下方式调用Apache Wink Rest(POST)调用,但它无效。我收到java.net.URISyntaxException。
secHandler.setUserName(userName);
secHandler.setPassword(passWord);
secHandler.setSSLRequired(false);
ClientConfig clientConfig = new ClientConfig();
clientConfig.handlers(secHandler);
RestClient restClient = new RestClient(clientConfig);
Resource resource = restClient.resource("http://xx.xx.xx.xx:9080/myprocess?action=start¶ms={\"inputName\":\"Test\"}");
String response response = resource.contentType(MediaType.APPLICATION_FORM_URLENCODED_TYPE).accept(MediaType.APPLICATION_JSON).post(String.class,"");
答案 0 :(得分:0)
Here is the code
secHandler.setUserName(userName);
secHandler.setPassword(passWord);
secHandler.setSSLRequired(false);
ClientConfig clientConfig = new ClientConfig();
clientConfig.handlers(secHandler);
RestClient restClient = new RestClient(clientConfig);
Resource resource = restClient.resource("http://xx.xx.xx.xx:9080/myprocess?action=start
String jsonString ="params={\"inputName\":\"Test\"}")";
String response response = resource.contentType(MediaType.APPLICATION_FORM_URLENCODED_TYPE).accept(MediaType.APPLICATION_JSON).post(String.class,jsonString);