Showing results for 
Search instead for 
Did you mean: 

Pre-request Script error


I've downloaded the REST API collection to my Postman for testing.  Upon submitting any of the requests, I encountered the following error:

There was an error in evaluating the Pre-request Script:TypeError: Cannot read properties of undefined (reading 'length')

Could you please advise how this issue can be resolved?




I understand you've encountered an issue while testing the REST API collection in Postman, specifically related to a Pre-request Script. The error message indicates a "TypeError: Cannot read properties of undefined (reading 'length')".

This error typically occurs when there's an attempt to access the 'length' property of an object or variable that is undefined at that point in the script.

Here are a few steps you can take to resolve this issue:

  1. Review Pre-request Script:

    Examine the Pre-request Script associated with the request that triggered the error. Look for any instances where the 'length' property is accessed or manipulated. Pay attention to variables and ensure they are defined before trying to access their properties.
  2. Check Variables:

    Verify that any variables used in the script are properly initialized and have values assigned to them. If a variable is undefined, attempting to access its 'length' property can result in this error.
  3. Handle Undefined Cases:

    Introduce conditional checks in your script to handle cases where variables might be undefined. For example:



if (myVariable && myVariable.length) {
    // Your code here


DebuggingUse console.log statements in your Pre-request Script to output variable values and identify where the error occurs. This can help pinpoint the specific line causing the issue.

Update Postman:

Ensure that you are using the latest version of Postman. Check for updates and install any available patches or new releases.Community Support:If the issue persists, consider seeking assistance on the Postman Community forums. Other users and Postman support staff may be able to provide additional insights and solutions.

After making necessary adjustments to your Pre-request Script, retest the request to see if the error is resolved. If you have specific code snippets from the Pre-request Script, feel free to share them for more targeted assistance.

I hope this guidance helps in resolving the issue.


I'm having the exact same issue with the latest Postman and the latest Cybersource collection.   Every attempt to run a request results in an error:

TypeError: Cannot read properties of undefined (reading 'length')

I've checked the Pre-request Script that comes with the collection and I see no reference to a property called "length".

I had the same issue last week