parse http response
Parse the response of the request to status, header and body.
Name | Description | Type | Modifier |
---|---|---|---|
response | HTTP response. | String | None |
status | (Optional) Variable to store the HTTP status code of the response. | String | None |
header | (Optional) Variable to store the HTTP header of the response. | String | None |
body | (Optional) Variable to receive the HTTP body of the response. | String | None |
None
This action may be used within the following project items: test modules and user-defined actions.
Suppose that you'd like to test a given Google API to send a message to a recipient with the following information:
- API under test: Users.messages: send.
- URI:
https://www.googleapis.com/gmail/v1/users/me/messages/send
- Authentication scheme: OAuth 2.0
- Header fields:
Content-type: application/json
- In the request body, supply a Users.messages resource with the following property as the metadata.
Property name Value Description raw bytes The entire email message in base64url encoded string. Tip:To encode a plain text string into a base64url encoded string, you can use the Online Base64URL encoder tool.- Raw body content:
To: logigearepgtest2@gmail.com Subject: This is a test mail   This is a test mail
- Base64url encoded body content:
VG86IGxvZ2lnZWFyZXBndGVzdDJAZ21haWwuY29tClN1YmplY3Q6IFRoaXMgaXMgdGVzdCBtYWlsCgpUaGlzIGlzIGEgdGVzdCBtYWls
- Request body declared in JSON format {"raw":"base64url encoded string"}
- Raw body content:
setting value
setting max show length 1000000
 
name value
local variable access token ya29.Ci-hAwpFBdalNfFs2F4ien63COLAoc5qpTB6OCA1M3OE1ncT7C-17tYDRvgQcdTKgw
local variable uri https://www.googleapis.com/gmail/v1/users/me/messages/send
local variable tm encoded mail content VG86IGxvZ2lnZWFyZXBndGVzdDJAZ21haWwuY29tClN1YmplY3Q6IFRoaXMgaXMgdGVzdCBtYWlsCgpUaGlzIGlzIGEgdGVzdCBtYWls
 
schema value
authenticate oauth 2 # access token
 
create http request
 
key value
add http header Content-type application/json
 
content
add http body # "{""raw"":""" & tm encoded mail content & """}"
 
uri method timeout variable expected code
send http request # uri POST 100 >>response 200
 
response status header body
parse http response # response >>status >>header >>body
- If the variables in arguments status, header, or body are left empty, TestArchitect supplies global variables with the names _status, _header, or _body, respectively.
- For a full list of returned HTTP status code, refer to Status Code Definitions.
- The returned contents of the HTTP header are automatically converted into JSON view. Whereas, the contents of the HTTP body are preserved as they are originally returned by the web service, such as XML, or JSON response, etc.
- In order to see full result returned from this built-in action, set max show length to a higher value.
- This action supports the <ignore> modifier. If the string
<ignore>
is present as the value of any of the arguments, or any argument contains an expression that evaluates to<ignore>
, the action is skipped during execution.