Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get access token with JMeter JSON Extractor and use it?

I'm trying to extract access token from the body response and use it in Header Manager for authorization. The response of the first request is Response

Then I use regular expression for extracting the token Json Extractor

Then I enter a variable into the Header Manager Header Manager

But when I run the script I receive an error: Listener

Also, I get an error: 2019-02-09 23:45:57,822 ERROR o.a.j.e.j.j.JSONPostProcessor: Error processing JSON content in JSON Extractor, message: Use bracket notion ['my prop'] if your property contains blank characters. position: 2 Error I assume that json path is incorrect

I have already researched a lot of questions here but they didn't help me What is wrong in my actions? Thanks for the response in advance!

like image 800
Andrew Chichick Avatar asked Dec 24 '22 01:12

Andrew Chichick


2 Answers

Use JSON Path Expressions as $.access_token

enter image description here

like image 146
Masud Jahan Avatar answered Dec 28 '22 06:12

Masud Jahan


You're using a Regular Expression inside a JSON Extractor, that's your problem.

You must use JSON Path expression instead.

So correct value for JSON Path Expressions is:

$..access_token

Since you have in "Names for created variables" token, you can then use it with:

${token}

like image 39
UBIK LOAD PACK Avatar answered Dec 28 '22 06:12

UBIK LOAD PACK