将curl请求转换为Java

时间:2017-01-03 08:08:41

标签: java curl

我有一个像下面的卷曲请求

curl --header "Content-Type: application/json" -X POST http://192.168.10.33:2003/jobs --data '{"path": "./examples/target/scala-2.10/mist_examples_2.10-0.0.2.jar", "className": "SimpleContext$", "parameters": {"digits": [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]}, "externalId": "12345678", "namespace": "foo"}'

我想将其转换为java,所以我正在做类似

的事情
Client client= Client.create();
WebResource resource = client.resource("http://192.168.10.33:2003/jobs");
String response = resource.type(MediaType.APPLICATION_JSON_TYPE).post(/*not sure what to do here*/);

那么如何将上面的curl请求映射到java?

1 个答案:

答案 0 :(得分:0)

我认为你应该写一些类似的东西:

String body = "<JSON here>";

String response = resource.
  type(MediaType.APPLICATION_JSON_TYPE).
  post(String.class, body);

here所述。

相关问题