jmeterpostmanbeanshell

I want to fetch ID based on provided name from api which returns both. I want to store this ID which will be used in another request


This api returns me dashboard_id and dashboard_name as highlighted in attached image. My requirement is to fetch dashboard_id based on dashboard_name using this api in jmeter? Both ID and Name are unique here. Is it possible to achieve this in jmeter?

Since we do not have any api which will return me dashboard_id based on dashboard_name. So wanted to use this current api which has both ID and Name, and based on Name I want to fetch ID, and ID will be used in different request.

Using Jmeter, I am providing user credentials and dashboard_id via 'CSV Data Set Config' that is being used in request, but too many ID's are confusing, so better we want to use dashboard_name which is more readable and add current api from where we want to fetch ID, so that ID can be used in another request.

I was trying to go though Beanshell Sampler to achieve this, but still didn't find a way to achieve it. Please suggest me a way to achieve this in jmeter?

enter image description here


Solution

  • You can use JSON Extractor and the following JsonPath query:

    $..[?(@.name == 'New Dashboard - 6')].dashboardId
    

    Full configuration:

    enter image description here

    You should be able to refer the extracted id as ${dashboardId} where required.

    Going forward please: