android - How to get a HEAD of a Retrofit call from an api endpoint that requires field in the request body? -


i trying examine headers of response api call made via retrofit 2.0.2 before downloading content.

my api interface looks following:

@headers({"accept: application/json", "origin: http://www.example.com"}) @head("profiles") call<void> getprofileheaders(@field("puids") string puid); 

please note api call requires me specify in body field called puids=%{uuid} list of uuids in order return response.

if download data without examining headers first, call interface this:

@headers({"accept: application/json", "origin: http://www.example.com"}) @formurlencoded @post("profiles") call<string> getprofile(@field("puids") string puid); 

now issue when try use getprofileheader() endpoint, following runtimeexception:

java.lang.illegalargumentexception: @field parameters can used form encoding. (parameter #1) 

in order use @field parameters (as suppose post method if required), have explicitly specify use @formurlencoded, can't make @head call that.

i bit puzzled how achieve want , missing?

basically know how can examine retrofit call's response headers before downloading actual body, of api endpoint requires field parameters?

cheers!

okhttp used retrofit has interceptors let modify or examine requests on fly. check out github documentation


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -