Tests script not running

I’m trying to simulate a server with webhook behavior. The idea is that we send a request to this server containing a “webhook_url” in the request body. Then the server immediately responds with a random GUID “id” in the response body. After a short delay, it should also send a POST request to the “webhook_url” with a body containing the GUID.

The problem is, when I test it by clicking “Try” in the Postman UI, it works fine and the Test scripts are run. However when I actually test it externally (i.e. via my node app), the Tests do not appear to run at all. Am I doing something wrong? How can I debug this? TIA

Here’s my script:

let res = pm.response.json();
let transcriptId = res.id;

var webhookUrl = req.webhook_url;
// Simulate the async call to the extracted webhook_url after a delay
setTimeout(function() {
  var webhookRequest = {
    url: webhookUrl, // Use the extracted webhook_url
    method: "POST",
    header: {
      "Content-Type": "application/json"
    body: {
      mode: "raw",
      raw: JSON.stringify({
        "transcript_id": transcriptId,
        "status": "completed"
  pm.sendRequest(webhookRequest, function(response) {
    // Log or perform actions based on the webhook response
}, 5000); // Simulated delay of 2000 milliseconds (2 seconds)

Hey @orbital-module-arch5 :wave:

Would you be able to expand on this point more, please? An example of what this looks/behaves like would be helpful.

@ dannydainton I have a NextJS 13 app on Vercel, with some API routes. On Vercel preview branches, the app is configured to make a call to our mock Postman server with the request I described above. The webhook_url provided is: the current Vercel app deployment URL + /api/v1/transcriptions. This is an API route for our app which I can monitor requests to in Vercel logs.

In summary, the flow is:

  1. NextJS app is triggered to make a request to {{postmanUrl}}/v2/transcript, with a body containing webhook_url pointing back at our app’s API route
  2. The Postman endpoint should return a random guid in the reponse
  3. After a delay, the Postman endpoint should send a POST to the webhook_url with a body containing the generated guid
  4. We can view the logs to confirm whether our app’s API route was hit

When I manually hit “Try” in the Postman UI with the real value for webhook_url pointing to our app (i.e. faking step #1), then steps #2-4 occur successfully. However, when I trigger step #1 for real in our app, only #2 appears to occur. I am unable to confirm #4 in our logs.

Here’s a simpler test I did:

[SUCCESS] Clicking “Try” in the Postman UI gives me correct response with guid, I can see activity in the console window, and I can confirm via Vercel logs that it made an outbound request to the webhook_url endpoint from the Tests script.

[FAIL] For the same postman example, I open the code snippet view and copy the cURL command. I execute the command, do NOT see console activity, and do NOT see any outbound request to webhook_url as evidenced in our Vercel logs.

Maybe my understanding is wrong. Should the Tests script always be run, or only when trying example requests within the postman application?

Have you tried creating an actual request, with all the same details, rather than doing that via an example?

There could be some slight differences in the way that those two different things work, when run programmatically.

Yes. My findings were that Test scripts are executed when running postman examples, but not run when the incoming request is from an external source.

Is that not true?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.