I am new to Retrofit Library. When I sending post request with headers parameters using hashMap using @HeaderMap
annotation.
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<String, String> headers = new HashMap<>();
headers.put("eventId", String.valueOf(1));
I am getting 404 error response. Please some one help me. I have reviewed some Stack Overflow links, but again I am getting this error.
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. try to call using postman if it is working fine in that or not.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.