Forum Discussion
Hey eissaeva
'${Request 1#Response}' simply means you've parameterised a certain value rather than hardcoding the thing.
The '${ }' just means 'parameter'
The 'Request 1#' bit means simply the Name you've defined for the Request - e.g. "Submit POST"
The 'Response' bit just means the response of the specified request.
So using the above info, the parm would be written as '${Submit POST#Response}
In the instructions page you've identified, I think you're talking about the following code snippet. This is about comparing XML responses - right?
So the code is as follows:
def request = context.expand( '${Request 1#Response}' )
def response = context.expand( '${Request 2#Response}' )
so here you're grabbing the response of Request 1 and passing it into the variable defined as 'request'
and you're grabbing the response of Request 2 and passing it into the variable defined as 'response'
Does that help at all?
Cheers,
Rich
Also, my response is in JSON format
Is it possible to convert it to XML?
- richie4 years agoCommunity HeroHey eissaeva
Easiest way to convert json to xml in a response is to add the 'Accept' http header to the request that generates the response.
The value you set for the header will be 'application/xml'.
This will set the response sent back from your endpoint as xml
Cheers
Rich- eissaeva4 years agoContributor
Thank you for this input, Rich
From the previous answer you provided "The 'Response' bit just means the response of the specified request."
'Response' - is just a string, not a variable holding the response, correct?
- nmrao4 years agoChampion Level 3@eisseava,
If your service doesn't provide XML response, then one have to write some to do the conversion.
By the way, why you need to convert json to XML?- eissaeva4 years agoContributor
Hi Rao,
Yes, I would like to know how to compare JSON responses (actual vs expected) but I was only able to find below (comparing xml documents)
https://support.smartbear.com/readyapi/docs/testing/scripts/samples/compare-xml.html
Any help on how to compare json responses in a similar manner would appreciate
My requirement is not just to print out the actual / expected but to print out their differences in groovy
Thanks,
Related Content
- 2 years ago
- 9 years ago
Recent Discussions
- 4 days ago
- 9 days ago