Search code examples
jmeterhttp-postuuidpayload

Generate the UUID when the input payload is read from external file


${__UUID()} is not working when sending the payload content which was read from an external file

  1. I'm making a post call with input payload read from an external file.
  2. In the HTTPRequest post body data, I'm using this function to read the external file : ${__FileToString(${__eval(./HTTP/payload.txt)},,)}
  3. I can verify that data from the external file is read and being used when the post call is being made.

The issue is that, when making the post call, in the payload, against ID element, ${__UUID()} is not replaced/parsed by the UUID value, the static text "${__UUID()}" is being sent in the payload.

How to generate the UUID when the input payload is read from external file ?

Note: i also tried reading the file content line by line in BeanShell PreProcessor, and sending it as body data, same issue, UUID function is not parsed.

{
   "id":"${__UUID()}",
    "fname":"Hello",
    "lname":"World"
}

Expected result is : ${__UUID()} should be parsed and the actual UUID value should be send as part of the request.


Solution

  • You should first read (FileToString) the file and then evaluate UUID (eval)

    ${__eval(${__FileToString(./HTTP/payload.txt,,)})}