Search code examples
jsonvariablesjmeterextractmultiple-value

Jmeter combine Json extractor variables to pass into request


There's a certain web request which has the following response:

{
"data": {
    "articles": [
        {
            "id": "1355",
            "slug": "smart-device-connectivity's-impact-on-homes-workplaces",
            "title": "Smart device connectivity's impact on homes, workplaces",
            "published_at": "2022-01-28T21:30:00.000Z",
            "avg_rating": 0,
            "click_count": 60,
        },
        {
            "id": "1363",
            "slug": "you-need-to-nurture-and-amplify-human-capabilities",
            "title": "You need to nurture and amplify human capabilities",
            "published_at": "2022-01-28T19:00:00.000Z",
            "avg_rating": 0,
            "click_count": 22,
        }]}}

There are a total of 702 records which may increase or decrease over the coming months. Now I have been successfully able to extract ID & slug into separate variables. My aim is to pass these two variables into another request in the following format so that I can eventually run that 702 times or number of times = ID array or slug array size:

testurl.com/insight/${id}/${slug}

Example: testurl.com/insight/1355/smart-device-connectivity's-impact-on-homes-workplaces testurl.com/insight/1363/you-need-to-nurture-and-amplify-human-capabilities

I made use of Foreach controller & was able to pass slug but ID does not work. Does anyone know the solution?


Solution

  • If you're using ForEach Controller for iterating slug variable the id one needs to be handed a little bit differently:

    putting everything together:

    testurl.com/insight/${__V(id_${__intSum(${__jm__ForEach Controller__idx},1,)},)}/${slug}