Skip to main content

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

PropertyDescriptionType
<action-id>Unique identifier for the actionstring
typeType of the actionstring
propsProperties specific to this action. Refer to props section for more details.object

props

PropertyDescriptionConflicts withDefault
methodHTTP methods such as GET, POST, PUT, DELETE
baseUrlThe URL without a path or query parametersfullUrl
pathThe remaining portion of the URLfullUrl
fullUrlThe complete URL, including the base URL and pathbaseUrl and path
headersA key-value pair of HTTP headers
bodyThe body of the request, as a string. Bytes are not currently supported.
trustAllEnables or disables trust for all server certificatesfalse
verifyHostEnables 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"]

KeyDescriptionType
statusCodeResponse status code for eg. 200long
headersResponse headers Map of String Key-Valueobject
bodyResponse bodyobject
timeTakenTime taken, in millisecondslong

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"
}
}