Reputation: 55
I Wrote this test where i post a contract in a backoffice system. I made a keyword with a forloop which picks up xmls from a systemfolder.
In order to make the test pass, i want to check the values in de response. When I use RF/Ride to perform this test it is not possible to get the responsebody, if i conduct the same test in Postman/SoapUI i can see the responsebody
When i ask for the response.headers i get the expected data
The test in Ride:
*** Test Cases *** XML
[Template] Template post contract BO
apitest1.xml
*** Keywords *** Template post contract BO
[Arguments] @{bestandlijst}
: FOR ${bestand} IN @{bestandlijst}
\ &{headers}= Create dictionary Content-type=application/xml
\ ${bestandophalen}= Get Binary File ${bestand}
\ Create Session Backoffice https://url
\ ${response}= Post Request Backoffice /isCOBOL(API_V1_ARCONTRACT) headers=&{headers} data=${bestandophalen}
\ log ${response.headers} -> this works
\ log ${response.body} -> this doesn't work
Response in Postman:
<?xml version="1.0" encoding="UTF-8"?>
<Retourbericht xmlns="http://url/schemas/things">
<Statuscode>OK</Statuscode>
<Statusmelding>Contract opgeslagen in de backoffice.</Statusmelding>
<TransactionResponse>Onbekend.</TransactionResponse>
</Retourbericht>
Error given in ride:
FAIL : Resolving variable '${response.body}' failed: AttributeError: 'Response' object has no attribute 'body'
Upvotes: 3
Views: 9747
Reputation: 386325
If you are using RequestsLibrary, it is built on top of the python requests library. This library returns a response object, but that object does not have a body
attribute. That is why you get the AttributeError.
You can use ${response.json()}
if you want the structured data, or ${response.text}
if you want the raw text of the response as a string.
Upvotes: 6