How To Assert On an Empty JSON Response?
Hey,
I have 2 REST requests - a POST and a GET. The POST updates the record (either create/update/delete) and I use the GET to verify the results of the POST.
I am trying to prove a record has been deleted from my CRM - I can't use JDBC (which would be nice and easy) - I can only use the GET method to prove the record no longer exists.
I am struggling!
Once the record is deleted, there is just nothing to assert on in the 'Outline' tab. If I check the RAW response - I can see the headers and an empty response for the body - e.g. [] (response is .json.)
I found the following https://stackoverflow.com/questions/18198482/how-to-check-that-a-soap-response-is-empty
and it indicated I could add in the script assertion type wiht the code as follows:
assert messageExchange.hasResponse() == false
But this actually fails when I run the GET for some reason.
Would anyone know why the above script assertion wouldn't work? The only thing I can think of is that its not working because there is some sort of response (even if the response just has headers and no body to the response). The original poster on stackoverflow said this worked for a null/empty response, but this isnt working for me.
I've run out of ideas and googling hasn't helped me. I could force the response to be xml (by using an Accept header on the GET request which would generate a <results> tag to assert on in the response - however other project requirements have forced me to get the response in .json which means theres nothing generated in the outline tab in the response.
Many thanks!
richie