我无法理解代号为one api的JSON put请求。我没有找到任何例子来提出这个请求。
问题: 1.我不确定是否需要发送内容长度参数。如果是,我如何发送它? 2.我必须发送请求正文,只带"true“,没有其他东西。没有可以使用req.addArgument()方法的键和值。3.是否必须使用buildRequestBody()方法覆盖请求。您能举个例子吗? 4.收到响应后如何验证结果?
任何帮助都会受到感谢。谢谢。
请找到下面的代码。
req.setUrl(identityUrl );
req.setPost(false);
req.setHttpMethod("PUT");
req.setContentType("application/json");
req.addRequestHeader("authorization", token);
req.addArgument("Content-Length", "4");
req.setReadResponseForErrors(true);
InfiniteProgress ip = new InfiniteProgress();
Dialog d = ip.showInifiniteBlocking();
NetworkManager.getInstance().addToQueueAndWait(req);
d.dispose();
JSONParser parser = new JSONParser();
Map map2 = null;
try {
map2 = parser.parseJSON(new InputStreamReader(new ByteArrayInputStream(req.getResponseData()), "UTF-8"));
} catch (IOException ex) {
ex.printStackTrace();
}https://stackoverflow.com/questions/38427137
复制相似问题