send http request

Send an HTTP request to a given resource.
NameDescriptionTypeModifier
uri

Uniform Resource Identifiers (URI) to identify a resource.

StringNone
method

An HTTP request method

Possible values:

  • GET: Request data from a specified resource.
  • POST: Submit data to be processed to a specified resource.
  • PUT: Replace all the current representations of the target resource with the uploaded content.
  • DELETE: Remove all the current representations of the target resource given by URI.
  • PATCH: The PATCH method is used to apply partial modifications to a resource.
  • HEAD: The HEAD method asks for a response identical to that of a GET request, but without the response body.
  • OPTIONS: The OPTIONS method is used to describe the communication options for the target resource.

Value SetGET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
timeout

(Optional) Amount of time to wait for an HTTP response from the server. (units: seconds)

Default Value: 300
StringNone
variable

(Optional) Variable to store the HTTP response.

StringNone
expected code

(Optional) Expected HTTP status code of the response (see ).

StringNone
response file

Full path of file location to which to save the returned response body on the test machine.

StringNone
None
This action may be used within the following project items: test modules and user-defined actions.
The following settings are applicable to this action: remove double quotes from cells.
Example - Case 1: Testing a given Google API to send a message to a recipient

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.
    Table 1. Request body
    Property nameValueDescription
    rawbytesThe 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"}
        
settingvalue
settingmax show length1000000
 
namevalue
local variableaccess tokenya29.Ci-fa76X0cjJXa2Lx0RM-fRyAQ6-6pboEX-iuT7PR-yYv6D-Rfbos7bs151wiL-O7w
local variableurihttps://www.googleapis.com/gmail/v1/users/me/messages/send
local variabletm encoded mail contentVG86IGxvZ2lnZWFyZXBndGVzdDJAZ21haWwuY29tClN1YmplY3Q6IFRoaXMgaXMgdGVzdCBtYWlsCgpUaGlzIGlzIGEgdGVzdCBtYWls
 
schemavalue
authenticateoauth 2#access token
 
create http request
 
keyvalue
add http headerContent-typeapplication/json
 
content
add http body# "{""raw"":""" & tm encoded mail content & """}"
 
urimethodtimeoutvariableexpected code
send http request# uriPOST100>>response200
 
responsestatusheaderbody
parse http response# response>>status>>header>>body
Example - Case 2: Testing SOAP over HTTP-based web services

Suppose that you'd like to test a given API of the GlobalWeather web service to get all major cities by a specific country name.

  • API under test: GetCitiesByCountry
  • URI: http://www.webservicex.com/globalweather.asmx
  • Header fields:
    • Content-Type: text/xml
    • SOAPAction: http://www.webserviceX.NET/GetCitiesByCountry
  • In the request body, get all major cities of Australia.
                    
                        <?xml version="1.0" encoding="utf-8"?>
                        <soap:Envelope
                            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                            xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
                            <soap:Body>
                                <GetCitiesByCountry
                                    xmlns="http://www.webserviceX.NET">
                                    <CountryName>Australia</CountryName>
                                </GetCitiesByCountry>
                            </soap:Body>
                        </soap:Envelope>
                    
                
        
settingvalue
settingmax show length1000000
 
namevalue
local variableurihttp://www.webservicex.com/globalweather.asmx
local variablesoap body<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><GetCitiesByCountryxmlns="http://www.webserviceX.NET"><CountryName>Australia</CountryName></GetCitiesByCountry></soap:Body></soap:Envelope>
 
create http request
 
keyvalue
add http headerContent-Typetext/xml
add http headerSOAPActionhttp://www.webserviceX.NET/GetCitiesByCountry
 
content
add http body# soap body
 
urimethodtimeoutvariableexpected code
send http request# uriPOST100>>response200
 
responsestatusheaderbody
parse http response# response>>status>>header>>body
Example - Case 3: Retrieving an attachment through returned response body

Suppose that you'd like to test a given API web service to return an image through an HTTP GET.

  • Full path of file location to which to save the returned response body on the test machine: D:\TestData\tmp\testfile.png
        
create http request
 
keyvalue
add http headerscrFileD:\TestData\tmp\testfile.png
 
urimethodvariableresponse file
send http request# api downloadGET>> tm resultD:\TestData\tmp\testfile.png
 
responsestatus
parse http response# tm result>> tm status
 
valueexpected
check value# tm status200
 
file
check file existsD:\TestData\tmp\testfile.png
  • Supported web services:
    • RESTful (Representational State Transfer architecture).
    • SOAP (Simple Object Access Protocol) over HTTP-based web services.
  • An HTTP request must be instantiated via create http request before calling this built-in action.
  • variable argument:
    • If the variable in argument variable has not been declared, the action creates it as a global.
    • If the variable argument is left empty, TestArchitect supplies a global variable with the name _result.
  • expected code argument:
    • Enter an expected HTTP status of the response. For example, 200 means that the request was successfully received, understood, and accepted. For a full list of HTTP status code, refer to Status Code Definitions.
    • When this value is provided, TestArchitect compares the returned status code against the expected status code. An automation error is generated, if these two values do not match each other.
  • response file argument: A full filename and extension must be declared. Otherwise, TestArchitect reports a warning automation and this argument is ignored.

    Notes: 
    • Network resources and mapping network drives are also supported.
    • On Windows: In order to specify mapping network drives, please disable User Account Control (UAC).
  • 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.

Copyright © 2025 LogiGear Corporation. All rights reserved. LogiGear is a registered trademark, and Action Based Testing and TestArchitect are trademarks of LogiGear Corporation. All other trademarks contained herein are the property of their respective owners.

LogiGear Corporation

1730 S. Amphlett Blvd. Suite 200, San Mateo, CA 94402

Tel: +1 (650) 572-1400