Forum Discussion

richie's avatar
richie
Community Hero
8 years ago

XPATH Query - trap GET Request Response Via Data Sink Step Query

Hi,

 

I'm struggling to capture the WHOLE response of an GET response to save to a Data Sink - the response is in XML.

I have a POST response and I'm saving this response to a Data Sink - the response is in JSON and I AM capturing the WHOLE POST response.

 

SO - for my response in JSON I can capture the whole response, for my response in XML I can only grab the specific tag value - I need to capture the WHOLE response rather than just a single tag.

 

I have the following hierarchy

 

Datasource(Directory) multiple files on local drive - fileContents property
POST Request (submitting fileContents property for each file)
DataSink1(records POST response to a file)
PropertyTransfer step (JSONPATH grabs POST response content to DataSink1)
GET Request (submits using CustRefID from previous POST request)
PropertyTransfer step (XPATH grabs GET response content to DataSink2)
DataSink2(records GET response to a file)
DataLoop (loops round to pick up next file on drive to start test case again)

As you can see from the hierarchy I am using Property Transfer and Data Sink steps to capture the responses of both a POST and a GET request.

 

As stated above - I can capture the WHOLE response of the POST (which is in JSON) but I can't capture the WHOLE response of the GET (which is in XML) 

 

 

 

The POST Response is JSON (Path Language setting on the Property Transfer is JSONPATH)

The GET Response is XML (Path  Language setting on the Property Transfer is XPATH)

 

The difference between the 2's responses is that the POST's response is JSON, whereas the GET's response is XML - and I'm assuming this is the root cause of why I can capture the whole response in the Data Sink for the POST, but I can't capture the whole response in the Data  Sink for the GET.

 

The XML structure in the GET response is as follows:

 

 

<results>
<result>
<child1>value</child1>
<child2>value</child2>
<child3>value</child3>
<child4>value</child4>
</result>
</results>

 

 

I'm wondering what I am doing wrong - does anyone know the reason why I cannot capture the whole GET response to the Data Sink like I can with the POST response?

 

I'm assuming I need to change the XPATH setting but I've searched around but I can't seem to find the XPATH for 'all child nodes below a parent'

 

When I use the XPATH 

//results[1]/result[1]

 

The transferred value is blank.

 

Can anyone give me any an idea how to change the XPATH so that ALL the XML is passed to the Data Sink?

 

It's really annoying because the POST response is JSON and I can grab all the results quite easily!

 

Thanks!

 

richie

 

  • Sorry - didn't respond cos I've been executing tests for 12 hours a day for the last 2 weeks.

     

    rao - thanks - your answer really helped out!

     

     

  • Glad that it helped and thank your coming back and accepting the solution.
  • nmrao's avatar
    nmrao
    Champion Level 3
    How about
    //*:results
    • richie's avatar
      richie
      Community Hero

      Sorry - didn't respond cos I've been executing tests for 12 hours a day for the last 2 weeks.

       

      rao - thanks - your answer really helped out!

       

       

      • nmrao's avatar
        nmrao
        Champion Level 3
        Glad that it helped and thank your coming back and accepting the solution.
  • groovyguy's avatar
    groovyguy
    Community Hero

    richie: You can try the following adjustment to xpath as seen below. That might help.

     

    //results[1]/result[1]/node()