recent posts

RESTinstance - How to Set Headers

Tip of the day

Setting headers in the RESTinstance library was surprisingly difficult for me at first, but it's actually quite simple. Initially, I had been passing in an entire JSON object with multiple values as you would normally for a header like you would in Postman, but in this case you only need to pass in a key value pair one at a time.

Let me demonstrate with an example of how to sign in as a user, retrieve the JWT token that gets returned, and reusing that JWT token so that I have authorized access to make a `GET` call to query the users list.
   POST      /auth/login   body={"email":"${username}","password":"${password}"}  
   ${jwt_token} = String   response body token    
   Set Headers   {"Authorization":"JWT ${jwt_token}"}  
   GET           /users  
If you wanted to add more headers, you can just do the following...
   Set Headers   {"Authorization":"JWT ${jwt_token}"}  
   Set Headers   {"Accept-Encoding":"gzip"}  

And that's all there is to Setting Headers in RESTinstance! Good luck!



RESTinstance - How to Set Headers RESTinstance - How to Set Headers Reviewed by JJ The Engineer on 8:25 AM Rating: 5

1 comment:

Powered by Blogger.