简体   繁体   中英

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?

What error do you get?

I was able to emulate the same

I saved your json in a variable在此处输入图像描述

Foreach controller 在此处输入图像描述

another JSON inside foreach 在此处输入图像描述

Using the extracted values在此处输入图像描述

Overall JMX structure在此处输入图像描述

Final output 在此处输入图像描述

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}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM