Bradley Kirkland
Bradley Kirkland

Reputation: 682

How do I add bearer token to JMeter

I have come from PostMan now using JMeter for stress testing, I have a POST method that works great with PostMan yet I can't seem to get the bearer token authenticating to work on JMeter. I have the same token in PostMan as JMeter (See Screenshots)

Any help or advice is appreciated. See screenshots:

enter image description here

enter image description here

enter image description here

enter image description here

Upvotes: 1

Views: 9131

Answers (2)

Dmitri T
Dmitri T

Reputation: 168072

If you're capable of running your request successfully using Postman - you should be able to record it using JMeter's HTTP(S) Test Script Recorder

  1. Start JMeter's HTTP(S) Test Script Recorder

  2. Configure Postman to use JMeter as the proxy

    enter image description here

  3. Run your request/test in Postman

  4. JMeter should capture the request and generate corresponding HTTP Request sampler and the HTTP Header Manager

More information: How to Convert Your Postman API Tests to JMeter for Scaling

With regards to your setup: the header name should be Authorization and the header value should start with Bearer followed by your token value

The main problem is that JMeter cannot reach the application on your local machine so make sure that the corresponding web server is started.

Upvotes: 1

Vova
Vova

Reputation: 3541

For using Bearer token, you should create HTTP Header Manager, what you have already added. Then add Key/Name what is used in request, mostly it's Authorization, but we should check it out. Please, provide Headers and Authorization tabs from postman. Then, add Bearer token to Value field. In my case I should provide one more key/value: Cookie. jMeter Simple Sample

Upvotes: 3

Related Questions