[英]404 Response with Retrofit POST request with Headers parameters
I am new to Retrofit Library. 我是Retrofit Library的新手。 When I sending post request with headers parameters using hashMap using
@HeaderMap
annotation. 当我使用
@HeaderMap
注释的hashMap发送带有头参数的post请求时。
Below is my code 以下是我的代码
@POST(Constants.UrlPath.POST_CLOSE_EVENT)
Call<ResponseBody> callDeleteEventRequest(@HeaderMap Map <String, String>id);
I am sending the headers using HashMap
here like this. 我在这里使用
HashMap
发送标题。
HashMap<String, String> headers = new HashMap<>();
headers.put("eventId", String.valueOf(1));
I am getting 404 error response. 我收到404错误回复。 Please some one help me.
请有人帮助我。 I have reviewed some Stack Overflow links, but again I am getting this error.
我已经回顾了一些Stack Overflow链接,但我再次收到此错误。
Try this: 尝试这个:
@FormUrlEncoded
@POST(Constants.UrlPath.POST_CLOSE_EVENT)
Call<ResponseBody> callDeleteEventRequest(@FieldMap Map <String, String>id);
add headers in your interface class: 在接口类中添加标头:
@Headers({"Content-Type: application/json",
"eventId: 1"})
@POST(Constants.UrlPath.POST_CLOSE_EVENT)
Call<ResponseBody> callDeleteEventRequest();
check your path Constants.UrlPath.POST_CLOSE_EVENT
is right or not. 检查你的路径
Constants.UrlPath.POST_CLOSE_EVENT
是对还是不对。 try to call using postman if it is working fine in that or not. 如果它在这方面工作正常,试着用邮递员打电话。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.