HTTP request: Reuse a single random email address in multiple locations

Question

How to reuse the same randomly generated email address in multiple places within an HTTP request in a .http file using the JetBrains HTTP client?

Answer

To use the same random email address in multiple locations within an HTTP request, create a custom variable and assign it the value of $random.email once, then reference that variable wherever needed.

Example:

###
@myEmail = {{$random.email}}

POST https://example.com/api
Content-Type: application/json

{
  "userEmail": "{{myEmail}}",
  "contactEmail": "{{myEmail}}"
}

This approach sets the variable myEmail to a single randomly generated email address, and that value is reused anywhere you reference {{myEmail}} in the request.

0 out of 0 found this helpful

Please sign in to leave a comment.

Have more questions?

Submit a request