Ask a Question

what is the meaning of '${Request 1#Response}'?

eissaeva
Contributor

what is the meaning of '${Request 1#Response}'?

Hi Community

 

https://support.smartbear.com/readyapi/docs/testing/scripts/samples/compare-xml.html

 

In above explanation, what is the meaning of '${Request 1#Response}'? Can you please provide an example 

 

Is there similar script for compare json documents?

13 REPLIES 13
richie
Community Hero

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

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

Yes, makes sense.

Is it possible to use this code to compare actual and expected response of the same request? How to achieve this?

Also, my response is in JSON format

Is it possible to convert it to XML?

Hey @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
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

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?

 

 

nmrao
Champion Level 3

@richie, this is only true provided the service is implemented like that. Doesn't work otherwise.


Regards,
Rao.
nmrao
Champion Level 3

@eissaeva, 'Response' is property name that readyapi internally defines and assign value on receipt of response.


Regards,
Rao.
VeenaDevi
Contributor

When you use "Get Data " and select any of Request, in this case, the Request in TestCase, as both have Rest Request 1 and 2 it just get the name, if you renamed your request then that name get replaced here.

 

 

( '${Request 1#Response}' )  <Request Name # and the specific Responce

( '${<Your RequestName>#Response}' )  <Request Name # and the specific Responce

richie
Community Hero

Hey @nmrao,

Yeah im aware but i was trying to go with the simplest answer

Nice one

Rich
if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
cancel
Showing results for 
Search instead for 
Did you mean: