WYSIWYG

http://kufli.blogspot.com
http://github.com/karthik20522

Tuesday, February 19, 2013

JMeter - Posting JSON

Apache JMeter is probably one of the most comprehensive Load/Stress testing tool out in the market that is free! One of the tasks that I recently was to load test a WebApi service with production data to simulate real world data. Unfortunately there were not many articles that discussed about a simple way of using jMeter to post data. Following is a step by step procedure to post JSON to a URI:

Step 1: Assuming you already have your root setup (thread group)



Step 2: Add a HTTP Request "Config Element" and fill up the "Server Name or IP" with your server address and port number i.e. if you have one and change the Http Request Protocol to http and Method to POST. Update the Http Request Path with the URI. In the Http Request Parameters, add a new row with the Value as "${somename}"



Step 3: Add "CSV Data Set Config" [Config Element] and add your Filename with the relative path and provide the same variable name "somename" as mentioned above. If you are not using a comma as the delimiter then add the delimiter. The options, "Recycle at EOF" when set to True would start back from the beginning of the file if the test reached the end of file.



Step 4: Add a Http Header Manager and set the content-type to application/json



Done.. Hit Start (ctl + R) and it should start posting JSON to your service.

Labels: