0

When I recorded the script for downloading a CSV file, only that HTTP request is getting a 400 response code. The audit history of the website displaying file is downloaded. When I hit the audit history download link, I get an internal server error.

Note: if I download the file with manual steps, the audit history download link is downloading the CSV file.

My payload has dynamic time stamps for file name suffix and activity Id

fileName: 
AAJCAA_5199_1312023_73446PM.pdf
activityId: 
87061

Please let me know how can I declare these parameters in the download file sampler.

3 Answers 3

1

Most probably it's a matter of correlation, i.e. these file name and activityId are somewhere in the previous responses and you need to extract them using a suitable JMeter Post-Processor and replace hard-coded values with the JMeter Variables from the Post-Processor.

In case if timestamp is the current timestamp - you can use JMeter's __time() function to generate it on the fly like:

${__time(ddMMyy-hmmssa,)}

enter image description here

1
  • I found the activityId in the previous request but not the file name. File name is autogenerated when the download action is completed. then how can i correlate the file name in regex? Feb 2, 2023 at 0:50
0

To handle the dynamic time stamp and activity ID in the download file sampler in JMeter, you can use the following steps:

  1. Add a Regular Expression Extractor to the request which generates the URL with dynamic values (e.g. activityId, timestamps).
  2. Extract the dynamic values using Regular Expression Extractor and store them as variables.
  3. Use the variables in the download file request, e.g. AAJCAA_5199_${activityId}_${timestamp}.pdf
  4. Make sure to check "Use caching" option to cache the binary content.
  5. Add the necessary headers and parameters in the download file request if needed.

Note: Make sure the Regular Expression Extractor is applied to the correct request and it successfully extracts the values.


Edit:

Ass you mentioned in the comment the file name is generated dynamically.

In this scenario, you can use a Correlation Extractor in JMeter to dynamically extract the file name from the response of the download request. Here are the steps to do this:

  1. Add a Correlation Extractor to the request where the file download is initiated.
  2. In the Correlation Extractor, specify the regular expression that matches the autogenerated file name in the response.
  3. Store the extracted file name as a variable, e.g. fileName.
  4. Use the extracted variable fileName in the file download request, e.g. ${fileName}_${activityId}_${timestamp}.pdf

Note: Make sure the Correlation Extractor is applied to the correct response and it successfully extracts the file name. You may also need to adjust the regular expression as needed to correctly match the file name.

2
  • I found the activityId in the previous request but not the file name. File name is autogenerated when the download action is completed. then how can i correlate the file name in regex? Feb 2, 2023 at 0:50
  • I've edited the answer to add information about the filename. Feb 3, 2023 at 2:52
-1

While working in a software qa consulting organization, I've tackled with several issues working with JMeter. Considering the above issue, there may be two different cases that can be considered.

Case-1

As per the response code, it seems that the issue is with the request in the script. Several factors are needed to be checked such as :

  • parameter
  • url
  • path of the given location
  • connection (required to check with sever/network team: if the application is subjeted to allow request from an external source)
  • authentication (if any)

Other solutions include:

  • try to record with blazemeter
  • if you have acccess you can use other licensed tools
  • try to use latest version of jmeter (apache-jmeter 5.5)

Case-2

As far as the file name and activity_ID is considered, it may be:

  1. Co-relation : As far as the file name and activity_ID is considered, both the file name and activityId may be found in the previous responses and you need to extract them and pass them using regular expression over hard-coded values.

  2. Timestamp : if in case the filename may be generated using the current time stamp, then the time-stamp regular expression can be used ${__time(ddMyyyy_hmmssa,)}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.