Varun Bali
Varun Bali

Reputation: 183

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?

Upvotes: 0

Views: 838

Answers (2)

Dmitri T
Dmitri T

Reputation: 168217

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}

Upvotes: 1

Rahul Jadhav
Rahul Jadhav

Reputation: 463

What error do you get?

I was able to emulate the same

I saved your json in a variable enter image description here

Foreach controller enter image description here

another JSON inside foreach enter image description here

Using the extracted values enter image description here

Overall JMX structure enter image description here

Final output enter image description here

Upvotes: 0

Related Questions