Apoorva6
8 years agoFrequent Contributor
How to compare node values in Rest services?
Hi Team, I have 2 requests. One will create the account and another will retrieve the account details. Once the account is created, I need to compare the the account number with the one retrieved...
- 8 years ago
Hi Apoorva6,
In the second response, check the Raw tab. Do you see the XML tags there? Probably not. It seems that your server is misconfigured to return "Content-Type: application/jason" instead of "application/json". You should ask your developers to fix that, because it might cause problems with other clients.
Assuming there are no XML tags in the actual raw response, you can use the JsonPath Match assertion:
JSONPath Expression:
$.invoiceNodeList[0].InvoiceNode.invoiceNodeDetails.nodeId
Expected result:
${Response 1 Step Name#Response#$.invoiceNodeDetails.account1Number}
Replace "Response 1 Step Name" with the corresponding step name.
If you prefer shorter expressions:
JSONPath Expression:$..nodeId
Expected result:
${Response 1 Step Name#Response#$..account1Number}
".." means recursive search.