[英]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.