Search code examples
jsonrestjmeterbeanshell

BeanShell Post Processor parse Json using Jmeter


I need to test rest api posting Json. I try to post Json Data by BeanShell PostProcessor using Jmeter. But BeanShell PostProcessor doesn't work or I couldn't write the right code.

My Json is : {"email":"selin@xxx.com","password":"123"}

You can see in the pictures below what i did.

enter image description here

enter image description here

enter image description here


Solution

  • I think you wanted to make an http request on an api. Follow this steps.

    1. Open a new instance of JMeter
    2. Under Test Plan, add a HTTP Header Manager to set the content type by navigating to Test Plan > Add > Config Element > HTTP Header Manager. Add new value for Name = “Content-Type” and value = “application/json” (without quotes).
    3. Under Test Plan, add a thread group by navigating to Test Plan > Add > Threads (Users) > Thread Group
    4. Under Thread Group, add a sampler of type HTTP Request by navigating to Thread Group > Add > Sampler > HTTP Request
    5. You can add various listeners to the Thread Group. I prefer Results in Table/Tree by navigating to Thread Group > Add > Listener > View Results in Table

    You can add JSON data manully like shown on the picture.

    JMeter Http Request Parameters

    There is a gist also

    This gist includes BeanShell Post Processor Version