[英]Converting curl request to Java
我有如下卷曲请求
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?
我认为您应该写这样的东西:
String body = "<JSON here>";
String response = resource.
type(MediaType.APPLICATION_JSON_TYPE).
post(String.class, body);
作为描述在这里 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.