3

First request for the JSON in response body which looks like this:

{"data":{"userId":"USR-0000000000000001","accessToken":"TKN-05TS53MFRVK2QYH2HMLD3J25WMH8IH6E767W","refreshToken":"RTK-88TLRIYE4YVJMWH2H4G0UQK83DVCWODFLX4X","expiresIn":"2018-03-16 20:14:00","tokenType":"bearer"}

I extract the value of the "accessToken" attribute using the "Regular Expression Extractor": regular expression

Then I pass the "Authorization" variable to the header, this step i need to put accesstoken to get information on my profile: enter image description here

But then showing me this response on the results tree enter image description here

and response showing

"{"error":{"errorCode":1001,"errorMessage":"Authentication failed"}}"

What i want is on the next request can sucessfully read the accesstoken. can somebody help if theres something wrong on this?

Thanks

3 Answers 3

2

Json Exractor also used to exctract the json resonse value. here below images are helpful for extracting the value from json . storing it in the variable and using it for the header request.

JsonExtractor Control

StoredVariable Used Http Header Request

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the recomendation :) yas it seems i will using JSON Extractor instead of the Regular Expression Extractor :)
0

You should put in the Regular expression extractor the name of the created variable.

Replace in regular expression from Authorization to accessToken because it is the name of the variable created that you are using

Comments

0
  1. You need to change header value to Bearer ${Authorization}, as per RFC 6750 it should start with Bearer and header values MAY be case sensitive

  2. It makes more sense to go for JSON Extractor instead of the Regular Expression Extractor, when it comes to JSON data regular expressions. You should be able to extract the token value using simple JSON Path query like:

    JMeter JSON Extractor

    More information: API Testing With JMeter and the JSON Extractor

1 Comment

Thanks for the help and recomendation :) yas it seems i will using JSON Extractor instead of the Regular Expression Extractor :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.