How to dynamically set list of headers in Retrofit 2 (Android)

Viewed 2682

We are trying to migrate to using Retrofit2 and I am having trouble with a requirement where we need to pass a set of dynamically generated headers (used for analytics) for every request.

@Headers is not supported at parameter level and since header field name vary based on the current activity, I cannot use @Header.

Is there a way to append the headers just before execute() ? (Looking for something similar to @QueryMap/@FieldMap but for headers)

NOTE: I do not have the list of headers while initializing the client (and hence cannot use the Interceptor to do this).

1 Answers
Related