HTTP Request

Verb: httpRequest

Sends an HTTP request to a server, returning the requested information.

Syntax

httpRequest --verb(Nullable<HttpVerb>) --url(String) [--headers(StringDictionary<String>)] [--username(String)] [--password(String)] --formatter(Nullable<HttpFormatter>) [--contentheaders(StringDictionary<String>)] --file(String) --source(String) [--data(String)] [--encoding(Nullable<EncodingType>)] [--mediatype(String)] [--cookiecontainer(CookieContainer)] [--proxy(ProxyVariant)] --noproxy(Boolean) [--timeout(TimeSpan)] (Boolean)=success (String)=value (Numeric)=statusCode (String)=reasonPhrase (StringDictionary<String>)=headers (StringDictionary<String>)=contentHeaders

Inputs

Script Designer Required AcceptedTypes Description
--verb Method Required HttpVerb HTTP request method. The available methods are:
  • Delete: Requests the origin server to delete the resource identified by the URL. This action can be interrupted by the server. Notes:
    • This action can be interrupted by the server.
    • The requirement client is not informed when the server stops action.
    • If the request is cached and the URL identifies one or more cached entities simultaneously, these entities become obsolete.
    • Responses for this method cannot be cached.
  • Get: Retrieves any information identified by the request URL. You can also specify conditions in the request headers. Note: Accepted conditions:
    • If-Modified-Since
    • If-Unmodified-Since
    • If-Match
    • If-None-Match
    • If-Range
  • Head: Retrieves information similarly to the Get method, but it only receives meta-information that can be stored instead of the message body. Note: The response metadata are identical to those obtained in the Get method. Use Head to test for valid links and to check for recent modifications.
  • Options: Requests information about communication options for the target server.
  • Patch: Applies partial modifications to a resource on the target server.
  • Post: Sends data to the target server.
  • Put Creates or replaces a resource on the target server.
  • --url URL Required Text Address for submitting the request.
    --headers Headers Optional String Dictionary<Text> Request headers with relevant information to the request. Note: If not specified, the command returns the available headers on the target server. Default headers:
    • Accept
    • AcceptCharset
    • AcceptEncoding
    • AcceptLanguage
    • Authorization
    • CacheControl
    • Connection
    • ConnectionClose
    • Expect
    • ExpectContinue
    • From
    • Host
    • IfMatch
    • IfModifiedSince
    • IfNoneMatch
    • IfRange
    • IfUnmodifiedSince
    • MaxForwards
    • Pragma
    • ProxyAuthorization
    • Range
    • Referrer
    • YOU
    • Trailer
    • TransferEnconding
    • UserAgent
    • Via
    • Warning
    --username User Name Optional Text User name required for server authentication, if available.
    --password Password Optional Text Password required for server authentication, if available.
    --formatter Formatter Only whenMethod is Post, Put, Patch HttpFormatter Body formatter, with available options:
  • Bytes
  • Form Url Encoded
  • Instance
  • Json
  • Text
  • XML
  • --contentheaders Content Headers Optional String Dictionary<Text> Headers of body content with information pertinent to the request.
    --file File Only whenFormatter is Bytes Text File that should be sent.
    --source Body Only whenFormatter is Text, FormUrlEncoded, Json, Xml, Instance Text, Http Content Formatted text that should be sent in the body of the request.
    --data Parameters Optional Text Parameters that should be sent in the body of the request.
    --encoding Encoding Optional EncodingType Text encoding. Options:
  • ASCII
  • Automatic
  • Big Endian Unicode
  • Operating System Default
  • Unicode
  • UTF32
  • UTF7
  • UTF8
  • --mediatype Media Type Optional Text Available when the format is Text. Specifies message body data type. Example: application/json ou application/xml.
    --cookiecontainer Cookie Container Optional Cookie Container The cookie container stores cookies that are used in the request.
    Note: An HTTP cookie is a small piece of data stored in the user's browser. It stores information such as logins and field data.
    --proxy Proxy Optional Proxy Receives a proxy variable, which contains the data of the proxy server, username and password.
    --noproxy Ignore Global Proxy Configuration Required Boolean When enabled, it ignores the proxy configured in the IBM Robotic Process Automation Studio installer or in the Settings Screen.
    --timeout Timeout Optional Time Span, Number, Text Maximum wait time for response.
    Note: In case no value is defined for the timeout parameter, the execution uses the timeout defined by the Set Timeout command. If that command is not used on the script, the default timeout is 5 seconds.

    Outputs

    Script Designer AcceptedTypes Description
    success Success Boolean If the request was submitted successfully, returns "True", otherwise returns "False".
    value Response Text HTTP response content coming from server to local machine.
    statusCode Status Code Number HTTP status code, informing what happened to the HTTP request.
    Note: The return ranges from 100 to 500, where:
  • 100: Informational
  • 200: Successful
  • 300: Redirects
  • 400: Errors in the request
  • 500: Errors on the server
  • reasonPhrase Reason Phrase Text Phrase sent by the server with the status code.
    Note: Status code is the three digits that show the error for the server and browser; The reason phrase is a short description of what this error means for better understanding of users.
    headers Headers String Dictionary<Text> Response header, with information pertinent to the request in question.
    contentHeaders Content Headers String Dictionary<Text> HTTP content headers as defined in RFC 2616.

    Example

    An HTTP GET request is made to the URL defined in the URL parameter, and its results are shown in the IBM Robotic Process Automation Studio console using the Log Message command.

    defVar --name status --type Numeric
    defVar --name reasonPhrase --type String
    defVar --name message --type StringDictionary --innertype String
    defVar --name success --type Boolean
    defVar --name response --type String
    defVar --name header --type StringDictionary --innertype String
    httpRequest --verb "Get" --url "https://jsonplaceholder.typicode.com/posts" success=success response=value status=statusCode reasonPhrase=reasonPhrase header=headers message=contentHeaders
    logMessage --message "Success: ${success}\r\n\r\nResponse: ${response}\r\n\r\nStatus: ${status}\r\n\r\nReason Phrase: ${reasonPhrase}\r\n\r\nHeader: ${header}\r\n\r\nMessage: ${message}" --type "Info"
    // Make an HTTP GET request at a Fake API website and returns results in the IBM Robotic Process Automation Studio console.
    

    Remarks

  • HTTP is a protocol that allows you to get resources like HTML documents. It is the basis of any data exchange on the Web and is also a client-server protocol. A complete document is reconstructed from the different subdocuments obtained, for example: text, layout description, images, videos, scripts and more.
  • See Also

  • Close SSH Tunnel
  • Create HTTP Content
  • Create Proxy
  • End SSH Session
  • HTTP Stream to File
  • Map to JSON
  • Open SSH Tunnel
  • Ping
  • Run SSH Command
  • Run Telnet Command
  • SOAP Request
  • SSH Login
  • Start Telnet Connection
  • Terminate Telnet Connection
  • Web Service Request