0
votes

I tried to design a test script of API Load Testing in JMeter 5.0. Here is my thread group info:

enter image description here

Below is the Body Data, I already added some variables and functions to it. You can also view the sample JSON Body Data at here:

    {
    "app_name": "Telekom",
    "source": "MOENGAGE",
    "moe_request_id": "req_${__threadNum}",
    "events": [
        {
            "event_name": "Email Opened",
            "event_code": "MOE_EMAIL_OPEN",
            "event_uuid": "${__UUID}",
            "event_time": ${__jexl3(${__time(,)}/1000,)},
            "event_type": "CAMPAIGN_EVENT",
            "event_source": "MOENGAGE",
            "uid": "${__counter(,)}-${__RandomString(7,ABCDEFG123456)}${uid}",
            "email_id": "${email}",
            "event_attributes": {
                "campaign_id": "${__RandomString(24,abcdefghijklmn123456789)}",
                "campaign_name": "July2021_16072021_LigaSuper_English",
                "campaign_type": "GENERAL",
                "campaign_channel": "EMAIL",
                "moe_delivery_type": "One Time",
                "moe_campaign_tags": [
                    "engagement"
                ],
                "moe_campaign_channel": "Email",
                "u_em": "${email}"
            },
            "user_attributes": {
                "PRODUCT_TYPE": "Unifi",
                "moengage_user_id": "60dc48d4d722040a2e78b788",
                "SERVICE_NO": "${uid}",
                "id": "${email}"
            },
            "device_attributes": {}
        }
    ]
}

I also include JSON Extractor to do correlation on the response body:

enter image description here

Here is the results in View Results Tree. Added Debug Sampler to see the whether my parameterization and correlation working or not. Fortunately, only my parameterization is working, while correlation is not.

enter image description here

Updated: This is example of response body:

enter image description here

I want to correlate at "rqUuid": "urn:uuid:1a5d8617-258c-49f7-b1a7-5b8ee71fb9fd" in the response body. Question is, is this the correct way to correlate the JSON Body? Do I need to correlate the response body although I already define the function "event_uuid": "${__UUID}" in the Body Data?

Thanks. Appreciate your help.

3

3 Answers

0
votes

You are using a regular expression to get your data from a JSON response using the JSON Extractor. You need to use JSON Path Expressions instead of using regular expressions.

If you want to extract event_uuid from the response, your json path expressions would be events[*].event_uuid

To get the first event_uuid of your events array objects, you can use events[0].event_uuid

0
votes

JSON Extractor allows you executing JsonPath queries and it looks like you're trying to use a regular expression there, it will result into a syntax error, you can see jmeter.log file for details:

enter image description here

You're showing us request data and asking about extracting values from the response, in order to be able to help we need to see at least partial (or better full) response data and what part of it do you need.

So far I can only give the following piece of advice: switch to Regular Expression Extractor and there is a chance it will start working without any changes

0
votes

You can use JSON Extractor or JSON JMESPath Extractor for extracting values from JSON responses.

Your JSON path expression should be responseHeader.rqUuid

enter image description here

You can evaluate the JSON Path expressions or JMESPath expression through the View Result tree or with online tools.

  1. View Result Tree enter image description here

  2. You can generate the expressions online with http://jsonselector.com/

  3. JMSE Path Evaluator https://jmespath.org

Sample JMX is uploaded to GitHub for your reference https://github.com/pragmatictesters/Pragmatic-Learning-JMeter-Examples/blob/master/TestPlan-StackOverFlow-68706730-JSON.jmx