![](/img/trans.png)
[英]How to replace variable struct in golang http.NewRequest POST with request body
[英]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.