Saving HTTP Response Code
Hi Parasoft,
I am trying to figure out how to save response HTTP code (200, 500) and added a Header Data Bank output item, but I do see anything that looks it would be for the header code. . Here is what is returned:
HTTP/1.1 200
Content-Type: application/json;charset=UTF-8
Date: Thu, 01 Nov 2018 16:22:46 GMT
Vary: Accept-Encoding
X-DOMAIN-SESSION-IDENTITY: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJlNWU4MDA5Yi1jYTMzLTQ1ZjMtODQ2NC02NjcyNGQxZWFkOTYiLCJhdWQiOiJlbnRlcnByaXNlLmNoYXJ0ZXIuY29tIiwidXNlckRhdGEiOiJ7XCJwb3J0YWxBY2NvdW50R1VJRFwiOlwiMjhhNTkwZmUtNjJmMy00YzRhLTg0OWMtZTI1MWRlOTA0OGM1XCIsXCJwb3J0YWxVc2VyR1VJRFwiOlwiZTVlODAwOWItY2EzMy00NWYzLTg0NjQtNjY3MjRkMWVhZDk2XCIsXCJlbnRpdGxlbWVudHNcIjpbXCJFWFRFUk5BTF9WSUVXXCIsXCJJTlRFUk5BTF9WSUVXXCIsXCJJTlRFUk5BTF9FRElUXCIsXCJWT0lDRV9FRElUXCIsXCJWT0lDRV9DRFJcIl0sXCJpbnRlcm5hbFVzZXJcIjpcInRydWVcIn0iLCJpc3MiOiJlbnRlcnByaXNlLmNoYXJ0ZXIuY29tIiwiZXhwIjoxNTQxNjkzOTg2LCJpYXQiOjE1NDEwODkxODYsImp0aSI6IjA1ZDYyNmE3LTgwYjktNGE3Mi05ODQ2LWRlZjY4OWVlZWY4MCJ9.PtZESdGG2LtuF1RPGjinJudwN5CUErpkq5KwYy9UjEE
X-Forwarded-For: 24.217.29.219
X-TXN-ID: 6d046518-dc87-4dee-9252-5865143eabd6
Connection: Close
It is the HTTP/1.1 value I want to save off.
Thanks in advance,
Bryan Cox
Comments
-
Hi Bryan,
To do this, I would recommend adding in a Text Data Bank to the response header. There, you can create an extraction and define the left-hand text as "HTTP/1.1 " and the right-hand text as " " (make sure you include the space character with both). Once you do so and configure the column name, you should be able to access the response code in subsequent test steps.
Ex:
Hope this helps!
0 -
Hey Thomas,
That worked.
Thanks
0 -
I have the HTTP status code in the text data bank and see it in the console but am unclear how to actually validate that I got the response code I was expecting.
0 -
You don't need a data bank if you just want to validate the response code you were expecting.
Simply configure the Valid HTTP Response Codes field in the Misc tab of your REST Client or Messaging Client.0