0
votes

I am getting error when setting up API test in Jmeter, same is working fine in POSTMAN. Using HMAC authentication. I have some basic knowledge of Jmeter new to the tool.
https://developer.firstdata.com/marketplace/api/authentication.html?shell#authentication.

Postman Pre-request Script Postman Pre-request Script

And Postman Header details And Postman Header details

Postman API response is working fine. Same as been work in Jmeter but I' getting response message as {"message":"HMAC signature cannot be verified, a valid date or x-date header is required for HMAC Authentication"} I have added JSR223 PostProcessor and HTTP Header Manager. and here are the details for both image attached below.

** JMeter - JSR223 PostProcessor** JSR223 PostProcessor

JMeter HTTP Header Manager HTTP Header Manager

1

1 Answers

1
votes

Copying and pasting code from Postman won't work in JMeter because:

  • Postman is a browser extension and is capable of executing JavaScript and according to JMeter project main page:

    JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).

  • If you're trying to run JavaScript code you need to choose the appropriate language from the dropdown enter image description here

  • JMeter doesn't include CryptoJS library, you will need to download it and load before running the JavaScript

  • Since JMeter 3.1 it's recommended to use Groovy language for scripting as this option provides maximum performance especially when it comes to "heavy" cryptographic operations so I would recommend re-writing your code in Groovy

  • I see you like screenshots so I include an example implementation as a screenshot here:

    enter image description here

More information on Groovy scripting in JMeter: Apache Groovy - Why and How You Should Use It