Reputation: 49
I'm trying to send an authentication token through the header of a Postman request (to be sent through JavaScript in the future), but I'm getting it wrong somewhere.
This is the REST method in Java:
@GET
@Produces("text/plain")
@Consumes("text/plain")
@RequestMapping(value = "/products/{id}", method = RequestMethod.GET)
public ResponseList getProducts(@PathVariable("id") String id, @HeaderParam("Authorization") String token) throws JSONException, IOException {
System.out.println( "id" + id);
System.out.println( "token" + token);
[...]
return products;
}
So, when I use the REST method, such as this, I get the id correctly:
http://localhost:8080/service/products/Gold as a GET. The id shows correctly in the system.out as Gold.
But I'm trying to send an "Authorization" value on the header as well using Postman, and 'token' comes back as null in the system.out.
Am I using the @HeaderParam incorrectly, or maybe setting the header improperly on Postman itself?
Thanks!
Upvotes: 1
Views: 3555