2
votes

all. This is the response I got back after a GET request:

{"id":30,
 "name":"ABC, Inc.",
 "clientRiskAssessment":{"clientId":30,
                         "generalScore":70,
                         "federalScore":45,
                         "internationalScore":20,
                         "updatedDate":"0001-01-01T00:00:00+00:00",
                      "url":"https://example.com/WebPortal/Config/Tax/index.html?IsFrame=true#/app/questionnaire-response/GeneralTaxClientQa/abd8d723-dc4a-e711-811b-00505683008b",
                         "formattedDate":"01/01/0001"}}

I can get the whole value of the "url" by using $..url in JSON Extractor - JSON Path Expressions in JMeter. Could anyone please give me a hint on how to get a tokens at the end of the url only and not the whole url value? This is the token I would like to extract at the end of the url: abd8d723-dc4a-e711-811b-00505683008b Thank you.

3
Perhaps, you might use Beanshell PostProcessor. See this answer (Point 3), you will need .replaceFirst(".*/", "")Wiktor Stribiżew
Thanks @WiktorStribiżew replaceFirst method only replaces the first character. I was able to get the token after changing it to replaceAllKiem Nguyen
Well, you do not need .replaceAll since only one match is expected. Anyway, both will work.Wiktor Stribiżew

3 Answers

0
votes

You can use RegexPostProcessor with the below configuration:

Regular Expression: url.*\/(.*?)"

Template: $1$

Match No: 1

This would always capture the token from the end of the url.

0
votes

This is how to do it to have the most stable extraction in my opinion :

Add to your HTTP Request:

Like this:

enter image description here

Where JSON Extractor is like this:

enter image description here

And Regex Extractor is :

enter image description here

-1
votes

You can use the following Regular Expression Extractor configuration in order to get this GUID-like structure:

  • Reference Name: anything meaningful, i.e. token
  • Regular Expression: ([a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-([a-f\d]){12})
  • Template: $1$

Demo:

JMeter GUI Regex

References: