Over a million developers have joined DZone.

Handling Variable Number of Request Parameters in Neoload

DZone's Guide to

Handling Variable Number of Request Parameters in Neoload

This brief tutorial will show you how to handle multiple request parameters using Neoload and JavaScript for efficiency.

· Performance Zone ·
Free Resource

SignalFx is the only real-time cloud monitoring platform for infrastructure, microservices, and applications. The platform collects metrics and traces across every component in your cloud environment, replacing traditional point tools with a single integrated solution that works across the stack.

If your request has a lot of parameters which are being passed to HTTP Request, creating a request to manually correlate the data will be a cumbersome process when instead, we can use scripting capabilities using JavaScript in Neoload to make a much easier and effective way of handling them.

Image title

Steps to Handle "Too Many Request Parameters" With Dynamic Values

  1. Correlate the request parameters using variable extractors.
  2. Using Javascript, construct the string with all the request parameters and store that in a variable.
  3. Change the Post Content Type to Text in HTTP Request.
  4. Pass the variable into the request.

Here is a practical explanation.

Capture the variables using variable extractors from the preceding request as below.

Image title

Click on edit and create the Regular expression as below and select Extract All Occurrences.

Image title

You would be able to see the extracted value under the test header as above.

Now drag and drop Javascript action on to the userpath as below and enter the following JavaScript Code:

Image title

var countinstring = context.variableManager.getValue("KeyString_matchNr"); // getting count of captured values and storing into the string
var countinint = parseInt(countinstring); // converting count to integer value

var string = "";

for (var i = 1; i <= countinint; i++) {
    var key = context.variableManager.getValue("KeyString_" + i); // getting each key variables
    var value = context.variableManager.getValue("ValueString_" + i); // getting each value variables

    string = string + key + "=" + value + "&"; // concatenating each key and value pairs

logger.debug("concatenated string=" + string);
string = string.substring(0, string.length - 1); //remove extra & 

// Inject the computed value in a runtime variable
context.variableManager.setValue("variableString", string); // storing the constructed concatenated string to a variable

Please refer to JavaScript API of Neoload community.

The final step is to change the Post Content type to Text as below and pass the captured value as a parameter.

POST requests with a text/... -type content. The contents of these requests may contain NeoLoad variables for generating dynamic content.

Image title

Now click on check user path and click on start checking to validate the scripts to check the variables being captured currently or not as below

Image title


This way we can handle any number of dynamic parameters.

SignalFx is built on a massively scalable streaming architecture that applies advanced predictive analytics for real-time problem detection. With its NoSample™ distributed tracing capabilities, SignalFx reliably monitors all transactions across microservices, accurately identifying all anomalies. And through data-science-powered directed troubleshooting SignalFx guides the operator to find the root cause of issues in seconds.

neoload ,scripting ,performance ,java-to-javascript ,organization ,request parameters

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}