Answered question

How to combine RegEx and variables in response validation?

I need to verify different responses for API calls. Call is switched between JSON and XML response record. Response should contain value previously collected from DB.

So, in JSON validated part of response looks like:

"documentId":2357751

in XML validated part of response looks like:

<documentId>2357751</documentId>

Value "2357751" is collected from database by SQL query and it is defined unde SQL variable that is called like:

${Document_Checklist.DOCUMENT_ID}

Merging validation requests to fit both XML and JSON record, validation should look like:

documentId[\"|\>][\:]*[\"]*2357751

Since mentioned value is dynamically changed by SQL request, I have tried to post validation as:

documentId[\"|\>][\:]*[\"]*${Document_Checklist.DOCUMENT_ID}

And that is the breaking point validation has failed... I have even tried to add literal char marks to RegEx, like this:

documentId[\"|\>][\:]*[\"]*\$\{Document_Checklist\.DOCUMENT_ID\}

... but no gain. Please help!

Miroslav T.
Miroslav T.

Miroslav T.

Level
0
5 / 100
points
Fousseyni B.
Fousseyni B.

Fousseyni B.

Level
2
1014 / 2000
points

Hello Miroslav,

Can't you use two assertions in the whole response on that same request ? The first one based on the documentId, the second based on the ${Document_Checklist.DOCUMENT_ID}

Best Regards,
Fousseyni B.

Did you find this useful ?

No (0)

Yes (1)

100%

100% of users found this answer useful