1

My Scenario:

  1. I am doing a POSt request that generates a rateID( UUID)
  2. Doing another POST request that uses this rateID
  3. I am also using 2 other fields in the body that is getting extracted by JSON Extractor but somehow this rateID is just getting passed as is

Sample Response body from 1st POST request

{
        "source": "USD",
        "target": "MXN",
        "RateId": "0f4a78a2d2b34849882f0154b9249345",
        "exchangeRate": 21.3909440000,
        "rateExpiry": "2020-09-14 20:30:20",
        "providerId": 2,
        "providerNm": "ZIGA-STATIC",
        "rawRate": 21.3376000000,
        "markupValue": 0.00250
 }

Sample request body from 2nd POST request

[{

  "source":"${source}",
  "target":"${target}",
  "RateId":"${RateId}",
  "buyAmount":100,
  "transactionSettlementDate":"2020-07-28",
  "transactionId":"${GUID}",
  "transactionTimestamp":"2020-07-28T17:35:17.866Z"

}]

Getting error

{"errorMessages":["Transaction #0: [invalid RateId ${RateId}]"]}

IS it not possible to use UUID like that?? I even tried using a Regex for extracting UUID ([a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}) but still no luck

Asking help from Jmeter experts in the community, please help

2 Answers2

0

From what you show, it looks like extraction of the 4 fields did not work.

You need to add to the first HTTP request 3 JSON extractors:

First one with for source variable with json path expression :

source

Second for target variable :

target

Last one for RateId

RateId

For Guid, it's not clear if it's just the value of RateId (why did you create a variable Guid and not just used ${RateId} and how is it filled in this case ?).

If it’s just a random uuid, you can use function UUID:

${__UUID()}

Otherwise clarify where it comes from.

See:

UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
0

You can extract 3 values in a single shot using JSR223 PostProcessor and the following Groovy code:

def response = new groovy.json.JsonSlurper().parse(prev.getResponseData())

vars.put('source', response.source)
vars.put('target', response.target)
vars.put('RateId', response.RateId)

Demo:

enter image description here

More information:

Dmitri T
  • 159,985
  • 5
  • 83
  • 133