Home > Net >  Send header to server
Send header to server

Time:04-26

To send the header to the server in Kathleen language with Retrofit library, I use the following form

But the header is not sent

@POST("testPost.php")
fun postNews(@Query("txt") txt:String) : Single<List<News>>

CodePudding user response:

The example you shared is not attaching any headers to the request. Check out the "Header Manipulation" chapter of Retrofit's documentation page to learn how to add headers.

CodePudding user response:

You Can try this :

@Headers({
   "Accept: application/vnd.github.v3.full json",
   "User-Agent: Retrofit-Sample-App"
})
@GET("users/{username}")
Call<User> getUser(@Path("username") String username);
  • Related