Search code examples
csvgetjmeterhttprequestload-testing

JMeter: Passing parameters to an HTTP GET request query string using CSV data


I am fairly new to JMeter and am creating a load test. I have a GET request in an HTTP Sampler that looks like this:

/myCalendar?c={calendarName}&l={location}&i={calendarId}&loc={locationId}&s={calendarEvent}&a={eventId}&t={epochTime}

The names shown in braces are the names of my parameters. Each of these parameters has its own .csv file, and therefore its own CSV Data Set config element. Each of these parameters are also linked to their respective CSV files in the "Send Parameters With the Request" field in the HTTP Sampler.

My tests are failing, but I can tell by clicking on the failed test indicator in my Results Tree that ALL of the parameters are returning the correct values from my .csv file. However, I have noticed that the test will pass in some cases if I hard-code only some of the values into the query string.

For example, this fails...

/myCalendar?c=calendarName&l=location&i=calendarId&loc=locationId&s=calendarEvent&a=eventId&t=epochTime

...but this passes:

/myCalendar?c=calendarName&l=BMJErIH4Mku4HwdHyuX2XA&i=84Rza73ERUmRGb99NWZytw&loc=locationId&s=calendarEvent&a=odH1gBRnH0moh5YN4tgczw&t=157963549

If I modify the request that passes by replacing the hard-coded epochTime with the parameter that points to the .csv file, I get the following error:

The server encountered an error processing the request. The exception message is 'Value cannot be null. Parameter name: edate

If I revert epochTime back to its hard-coded value and substitute the other three hard-coded values with their associated parameters, I get the following error:

The server encountered an error processing the request. The exception message is 'bad base64 conversion to GUID

I realize that this can be a different issue entirely, but these values do work when hard-coded into the query string so I don't understand why they would not work if pulled from a .csv file.

Finally, it is worth noting that I do have single-parameter test cases that work with the following syntax where 'Birthday' is a user-defined variable as shown below. I have found that using this syntax in a query string with multiple variables throws an exception at the first '{' character.

myCalendar/${Birthday} 

Any assistance would be greatly appreciated!


Solution

  • The reason that my tests were failing was simply because I was entering the wrong information into the Path field in the HTTP Request Sampler.

    Initially, my path looked like this,

    /myCalendar?c=calendarName&l=location&i=calendarId&loc=locationId&s=calendarEvent&a=eventId&t=epochTime
    

    and the parameter name/value pairs in the "Send Parameters With the Request" field were:

    • calendarName, ${calendarName}
    • location, ${location}
    • calendarId, ${calendarId}

    I learned from the comment below my question that the query string should not be included in the path field, so everything after the question mark should be handled in the "Send Parameters With the Request" field. So the path should look like this:

    /myCalendar?
    

    And the names in the name/value pairs should use the variable that exists before each equals sign like this:

    • c, ${calendarName}
    • l, ${location}
    • i, ${calendarId, etc.}

    All of my tests are passing now and iterating through my multiple .csv files as expected.