繁体   English   中英

HTTP 带有请求正文的 POST

[英]HTTP POST with request body

对于此请求,我试图设置实体,但是当我执行request.setEntity时,它说需要类型HttpEntity ,在将其作为request.setEntity((HttpEntity) entity) HttpEntity为 HttpEntity 时它仍然给我异常。

final HttpPost request = new HttpPost(url);
    String json = "{\n"
        + "      \"id\": \"1\",\n"
        + "      \"method\": \"GET\",\n"
        + "      \"url\": \"https://graph.microsoft.com/v1.0/groups/xyz/members\"\n"
        + "    }";
    StringEntity entity = new StringEntity(json);
    request.setEntity(entity);

我使用的是“com.signalfx.shaded.apache.http.entity.StringEntity”而不是导致问题的“import org.apache.http.entity.StringEntity”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM