HTTP::CLIENT
Sends an HTTP request.
Syntax
actions:
<action-id>:
type: HTTP::CLIENT
props:
method: <method>
baseUrl: <baseUrl>
path: <path>
fullUrl: <fullUrl>
headers:
<headerName>: <headerValue>
body: <body>
trustAll: <trustAll>
verifyHost: <verifyHost>
Properties
Property | Description | Type |
---|---|---|
<action-id> | Unique identifier for the action | string |
type | Type of the action | string |
props | Properties specific to this action. Refer to props section for more details. | object |
props
Property | Description | Conflicts with | Default |
---|---|---|---|
method | HTTP methods such as GET, POST, PUT, DELETE | ||
baseUrl | The URL without a path or query parameters | fullUrl | |
path | The remaining portion of the URL | fullUrl | |
fullUrl | The complete URL, including the base URL and path | baseUrl and path | |
headers | A key-value pair of HTTP headers | ||
body | The body of the request, as a string. Bytes are not currently supported. | ||
trustAll | Enables or disables trust for all server certificates | false | |
verifyHost | Enables or disables hostname verification (for SSL/TLS) | true |
Example
tests:
httpPostTest:
tasks:
- action: actions.httpPost
validate: scripts.validateHttpOk
actions:
httpPost:
type: HTTP::CLIENT
props:
method: POST
fullUrl: https://httpbin.org/post
headers:
"Content-Type": "application/json"
body: >-
{ "name": "Foo" }
scripts:
validateHttpOk: assert context["last_output"]["statusCode"] == 200
Output
📝 Note: Can be accessed using context["last_output"]
Key | Description | Type |
---|---|---|
statusCode | Response status code for eg. 200 | long |
headers | Response headers Map of String Key-Value | object |
body | Response body | object |
timeTaken | Time taken, in milliseconds | long |
Example output
{
"statusCode": 200,
"timeTaken": 155,
"headers": {
"Date": "Tue, 12 Apr 2022 01:55:00 GMT",
"Expires": "-1",
"Cache-Control": "private, max-age=0",
"Content-Type": "text/html; charset=ISO-8859-1",
"P3P": "CP=\"This is not a P3P policy! See g.co/p3phelp for more info.\"",
"Server": "gws",
"X-XSS-Protection": "0",
"X-Frame-Options": "SAMEORIGIN",
"Set-Cookie": "NID=511=lplkaFWU8aJrkt_qmurhwdwL9pTk8hI71kFyZDUHvLZgZ8nWx1_Jogk5VMEFezqX8tf-ikzJ-kIk-lfuclnOfDR3-uU1WLXuqk2FyBnb3gKJUTvm2kTjERCIQYs2QE7E3zLqw0DxKxqfWG5VN0UPV3kc5QnUw1C_3p9Hz9qFIZI; expires=Wed, 12-Oct-2022 01:55:00 GMT; path=/; domain=.google.com; HttpOnly",
"Alt-Svc": "h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000,h3-Q050=\":443\"; ma=2592000,h3-Q046=\":443\"; ma=2592000,h3-Q043=\":443\"; ma=2592000,quic=\":443\"; ma=2592000; v=\"46,43\"",
"Accept-Ranges": "none",
"Vary": "Accept-Encoding",
"Transfer-Encoding": "chunked"
},
"body": {
"id": 123,
"name": "Gov. Bhishma Asan",
"email": "bhishma_asan_gov@reichert-lang.co",
"gender": "male",
"status": "inactive"
}
}