Thursday, July 4, 2019

Recording /Testing Curl APIs Using Jmeter

Many times we came across the situation to test the Curl Rest APIs but the challenge is to record them as making custom HTTP request embed error most of the times while preparing scripts for them.

There are mainly two ways to record the curl APIs when we are taking in regard to the Jmeter.One process can be used to capture the CURL request in any type of proxy

Method 1 : Curl To Test Plan convertor in Jmeter 5.1
 New functionality has been introduce in Jmeter 5.1 in which we can give curl as input to the jmeter and it gets converted to the HTTP test plan.Below are the step for the same.

Step 1: Select "Import from Curl" from Tools in JMeter 5.1







Step 2: Past the required Curl command  and press convert to http plan








Step 3: You can see that Curl has been converted to normal HTTP request now you can test the same





Method 2:
There are some situation when jmeter is not able to parse the complex Curl using the convert utility.
at this time we would require method of capturing CURL using proxy on command line

for this we need to install the CURL in windows machine then then need to download the curl certification and then set the path of curl.exe to PATH in environment variables and then capture the CURL by configuring proxy on system and executing CURL on command line as follows

Step 1: Installing CURL

macOS: Already available 

If you have Windows, you can download and install cURL as follows.
  1. In Windows, create a new folder called curl in your C: drive.
    C:\curl
  2. Go to http://curl.haxx.se/download.html and download one of the following zip files:
    • If you have a Windows 64 system, scroll to the Win64 - Generic section and look for the latest Win64 ia64 zip version with SSL support. It's normally second in the list. Click the version number to start the download.
    • If you have a Windows 32 system, scroll to the Win32 - Generic section and look for the latest Win32 zip version with SSL support. It's normally second in the list. Click the version number to start the download.
  3. Unzip the downloaded file and move the curl.exe file to your C:\curl folder.
  4. Go to http://curl.haxx.se/docs/caextract.html and download the digital certificate file named cacert.pem.
    The PEM file contains a bundle of valid digital certificates. The certificates are used to verify the authenticity of secure websites. They're distributed by certificate authority (CA) companies such as GlobalSign and VeriSign. The PEM file allows cURL to connect securely to the Zendesk API using the Secure Sockets Layer (SSL) protocol.
  5. Move the cacert.pem file to your C:\curl folder and rename it curl-ca-bundle.crt.
  6. Add the curl folder path to your Windows PATH environment variable so that the curl command is available from any location at the command prompt. Update the variable as follows:
    1. In the Start menu, right-click This PC and select More > Properties.
      Note: In Windows 7, right-click Computer and select Properties.
    2. Click Advanced System Settings.
    3. In the Advanced tab, click the Environment Variables button on the lower right side.
    4. Select the "Path" variable in System Variables, and click Edit.
    5. In the Edit environment variable dialog box, click New and add the path to the curl.exe file. Example: C:\curl.

      Windows 7: In the Variable Value textbox, append a semicolon to the value, followed by the path to the curl.exe file. Example: ;C:\curl


    1. Keep clicking OK to accept the change and close the dialog box.
Step 2:  Configure System Level Proxy :
Refer to the http://www.lalitgarg.in/2017/01/load-test-desktop-applications-using-jmeter.html

Step 3: Configure and Start proxy on Jmeter/Burpsuite/ any proxy tool

Step 4: Execute Curl command with --proxy localhost:port arguments and you will see the Request  captured in






Happy Testing !!!!!