How to dynamically set headers in Retrofit (Android)

前端 未结 4 675
无人及你
无人及你 2020-11-29 01:07

I am using an API that uses an authorization scheme that requires a special \"X-Authorization\" header to be set to authenticate the request. For example, this Retrofit setu

4条回答
  •  失恋的感觉
    2020-11-29 01:45

    A request Header can be updated dynamically using the @Header annotation. A corresponding parameter must be provided to the @Header. If the value is null, the header will be omitted. Otherwise, toString will be called on the value, and the result used.

    @GET("user")
    Call getUser(@Header("Authorization") String authorization)
    

提交回复
热议问题