How to fetch certain value from response?

40 views
Skip to first unread message

Priya

unread,
Mar 22, 2023, 4:51:21 PM3/22/23
to REST assured
Hello,
Need some help.

I have a reportRequestId = 07b value fetched from my previous statement.
My goal is to fetch the reportRequestId from below payload and assert with
the previous one to make sure it matches.
I have a long response as shown below where i can see several reportRequestId.
How do i get reportRequestId=07b and compare with the previous value?


{
        "reportRequestId": "03d",
        "templateId": 6,
        "orgId": "Organization_db87a2e5",
     },
    {
        "reportRequestId": "067",
        "templateId": 6,
        "orgId": "Organization_db87a2e5",
     
    },
    {
        "reportRequestId": "07a",
        "templateId": 6,
        "orgId": "Organization_db87a2e5",
   
    },
  {
        "reportRequestId": "07b",
        "templateId": 6,
        "orgId": "Organization_db87a2e5",
   
    },

  {
        "reportRequestId": "07d",
        "templateId": 6,
        "orgId": "Organization_db87a2e5",
   
    }

}

Thanks,
Priya

Sakshi Aggarwal

unread,
Mar 23, 2023, 2:15:16 AM3/23/23
to rest-a...@googlegroups.com
Hi Priya,

Try to use below code. It may work.

Jsonpath js = new Jsonpath(response);
String org = response.get("orgId");

--
You received this message because you are subscribed to the Google Groups "REST assured" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rest-assured...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rest-assured/73357c22-5558-40b3-adff-0240f77e1a15n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages