X-REQUEST-ID

Solved! Go to solution
tokenizacion2
New Contributor

X-REQUEST-ID

where the x-request-id value is obtained for tests from postmanimagen_2025-01-28_112758878.png

 

2 REPLIES 2
SyedSa
Community Moderator

Re: X-REQUEST-ID

Hi @tokenizacion2, Thank you for reaching out. An agent will get back to you as soon as possible. Until then, if any community member knows a solution, feel free to reply in this thread.

DianaVisaPM
Visa Developer Support Specialist

Re: X-REQUEST-ID

Hey @tokenizacion2,

 

The `X-REQUEST-ID` is a unique identifier used to trace and debug API requests. It's especially useful for tracking the lifecycle of a request across various systems and

services. When working with the Visa Developer Platform, you can use Postman to generate and include this header in your API requests for testing purposes.

 

Here's how you can obtain and use the `X-REQUEST-ID` value in Postman:

1. Generate a Unique `X-REQUEST-ID`:
- You can manually generate a unique identifier or use Postman's built-in functionalities.
- A common approach is to use a UUID (Universally Unique Identifier).

2. Add the `X-REQUEST-ID` Header in Postman:
- Open Postman and navigate to the request you want to test.
- Go to the "Headers" tab.
- Add a new header with the key `X-REQUEST-ID` and a unique value (e.g., a UUID).

 

Here is an example of how to add the `X-REQUEST-ID` header in Postman:

1. Open the Headers Tab:
- In your Postman request, click on the "Headers" tab.

2. Add the Header:
- In the "Key" field, enter `X-REQUEST-ID`.
- In the "Value" field, enter a unique value. You can generate a UUID using Postman's built-in functionality or an external UUID generator.

Here is a step-by-step guide to generating a UUID in Postman using JavaScript in a Pre-request Script:

1. Open the Pre-request Script Tab:
- In your Postman request, click on the "Pre-request Script" tab.

2. Add the Script to Generate a UUID:
- Paste the following JavaScript code to generate a UUID and set it as an environment variable:

 

```javascript
// START 
// Function to generate a UUID
function generateUUID() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
var r = Math.random() * 16 | 0,
v = c === 'x' ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
}

// Generate UUID and set it as an environment variable
postman.setEnvironmentVariable('x-request-id', generateUUID());
// END 
```

 

3. Use the Environment Variable in Headers:
- In the "Headers" tab, set the value of the `X-REQUEST-ID` header to `{{x-request-id}}`.

This way, each time you run the request, Postman will generate a new UUID and include it in the `X-REQUEST-ID` header. This is useful for tracking and debugging purposes.

 

Example Header Configuration in Postman:
- Key: `X-REQUEST-ID`
- Value: `{{x-request-id}}`

 

By following these steps, you can obtain and use the `X-REQUEST-ID` value for your tests in Postman, ensuring each request has a unique identifier for better traceability.




Thanks,

Diana



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.