I want to make a request with two headers in an Android app, the first one has a parameter. I tried this:
@Headers("Content-Type: application/json")
@GET("/ebuzon/client/show")
Call<Client> showClient(@Header("Authorization") String token);
call = api.showClient(" Bearer " +MySharedUser.getInstance().getToken());
401 UNATHORIZED
Edited: this should work, see @Robert answer. My problem was also updating token
@GET("/ebuzon/client/show")
Call<Client> showClient(@Header("Authorization") String token,
@Header("Content-Type") String appJson);
call = api.showClient(" Bearer" +MySharedUser.getInstance().getToken(), "application/json");
401 UNATHORIZED
@Headers({"Authorization: Bearer {token}","Content-Type: application/json"})
@GET("/ebuzon/client/show")
Call<Client> showClient(@Path("token") String token);
IllegalArgumentException: URL "/ebuzon/client/show" does not contain "{token}". (parameter #1)
I am doing the same in angular like this and it's working
var obj = this.http.get("/ebuzon/client/show",
{headers: new HttpHeaders().set("Authorization", " Bearer "+ this.token).append("Content-Type","application/json")})
.map(res => {
console.log(res);
return res
})
.catch(err => {
console.log(err);
return err;
})
return obj;
Thanks for any help.