Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I output information in pre-request script

Tags:

postman

Using the standalone version of Postman, how do I output some debug information in Postman pre-request script?

The code below works great for tests (post-request) but not for pre-request since there is no tests[] array.

var jsonData = JSON.parse(responseBody);
tests["key = " + jsonData.key] = true;              // debug message
tests["value = " + jsonData.value] = true;          // debug message
like image 371
Veener Avatar asked May 16 '17 16:05

Veener


People also ask

What is pre-request script?

Pre-request scripts are a piece of code that will run before the execution of a request. It runs in the Postman sandbox and allows us to add dynamic behavior to request execution.


1 Answers

The only way I could find to accomplish this is by using:

console.log("key = " + key);
console.log("value = " + value);

And then open up the Postman console (Cmd + Option + C / Ctrl + Alt + C) to view the debugs logs in a different window.

like image 88
Veener Avatar answered Jan 04 '23 05:01

Veener