Regarding the GET error in console due to pre-request script

Question: I have written a pre-request script to get the data from the external json file and use it in the request body in my POST method. Only one POST method is present in my collection. But when executing the script I am getting GET issue in the console 15 times due to the loop in pre-request script and then POST request is executing , I have tried every possible way but still getting same issue. As soon as I am removing the pre-request script …not getting the GET issue

any global or environment variables is not created and only one POST request is present in the collection.

Please do suggest how to remove this issue

That is not how you format sendRequest(). For example, you have not included the URL.

Have a look at the following link for the correct format.

Test script examples | Postman Learning Center

Your sendRequest() is not including a body. Setting the global variables (pm.variables.set) does not mean they will be used in the request.

Have a look at the following link for an more advanced example that incorporates a body.

Sending requests from scripts | Postman Learning Center

1 Like