How do i save response codes from the prescript selection

Your question may already have an answer on the community forum. Please search for related topics, and then read through the guidelines before creating a new topic.

Here’s an outline with best practices for making your inquiry.

My question:
How do i save the response code from the prescript when i use sendNextRequest in my test

Details (like screenshots):

How I found the problem:

I’ve already tried:

Hi @jayholman

Could you confirm what you mean, please?

The pre-req will complete before the HTTP request is sent. So unless the call has been made you won’t have a response code.

Pre-Req Execution → Request Sent → Response Received (response code returns here) → Test Script Execution.

Are you looking for the response code from a previous response in your setNextRequest flow?

I have an array i am cycling through and each value is suppose to return a different response code. When each of them run, I want to save the response in the global/envirnoment so i can use them in the Tests.


token = pm.globals.get("token")
var testValue = pm.globals.get("token");
var sessions = [token,"fat"];
currentSession = sessions.shift();
pm.globals.set("test1", currentSession)
if( pm.globals.get("test1") == token && pm.globals.get("nextTest") == true) {
    pm.globals.set("postive", true)
    pm.globals.set("current", "pos")
    currentSession = sessions.shift();   
    pm.globals.set("test1", currentSession)
if( pm.globals.get("test1") == "fat" && pm.globals.get("nextTest") == true) {
   pm.globals.set("400null", true)
    pm.globals.set("current", "neg")


var testValue = pm.globals.get("token");
var sessions;

 if (  sessions && sessions.length > 0 ){
} else {

using does not work in the prescript