[英]Bad request with retrofit when using no arguments and no body, how is this possible?
[英]Retrofit 2: 400 Bad Request when having body
我正在尝试执行状态更新PUT请求。 以下示例在邮递员中返回200:
网址:
http://www.example.com/users/3/status?seId=1&dt=2016-11-01T00:00:00Z
标题:
内容类型:application / json
字符集:utf-8
授权:承载者LONG_TOKEN_HERE
身体:
{“状态”:1}
这是我的Retrofit 2请求的结构:
@PUT("users/{id}/status")
Call<Void> updateEventStatus(@Header("Authorization") String token,
@Path("id") int id,
@Query("seId") int seId,
@Query("dt") String dateTime,
@Body Status status);
请求的URL与Postman中的相同,标头也是如此,因此我怀疑它与正文有关。 Status
只是一个包装类,具有一个名为status
int字段,我通过遵循此答案创建了该字段(我对凭据进行了相同的操作,并且效果很好)。 我也尝试在int
类型的主体中设置状态,但也会导致Bad Request。
知道Postman请求和Retrofit 2请求之间有什么区别吗? 谢谢!
编辑:这是翻新2中的originalRequest
:
Request{method=PUT, url=http://example.com/api/users/3/status?seId=0&dt=2016-10-04T05:30:00Z, tag=null}
headers: Authorization: Bearer LONG_TOKEN_HERE
contentType: application/json; charset=UTF-8
content:
0 = 123
1 = 34
2 = 115
3 = 116
4 = 97
5 = 116
6 = 117
7 = 115
8 = 34
9 = 58
10 = 51
11 = 125
Translated content:
{"status":3}
最终,这是服务器端的错误(我最初收到一个错误的seId,然后尝试使用不存在的seId进行PUT)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.