Apache Wink - 在URL中发送JSON字符串

时间:2013-01-10 17:12:58

标签: java json rest apache-wink

网址为:http://xx.xx.xx.xx:9080/myprocess?action=start&params= {\“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&params={\"inputName\":\"Test\"}");
 String response  response = resource.contentType(MediaType.APPLICATION_FORM_URLENCODED_TYPE).accept(MediaType.APPLICATION_JSON).post(String.class,"");

1 个答案:

答案 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);