我有以下代码来创建JSON对象:
Client client = ClientBuilder.newClient();
//response is the value of some GET request I performed before
JSONObject root=new JSONObject(response.readEntity(String.class));
//url is assigned to URL to which I wanted to POST.
WebTarget target2=client.target(url);
Response response2=target.request(MediaType.APPLICATION_JSON_TYPE);
response2.post(*what goes here*);
我需要在最后post
内放入什么?
答案 0 :(得分:0)
"在帖子功能里面究竟应该写什么。"
查看SyncInvoker
API。查看不同的post
方法。您将根据所需的响应类型选择其中一种。
Entity
参数可以简单地写为Entity.json(yourRequestObject)
,它会自动将请求配置为Content-Type:application/json