Execute Web POST

Verb: webPost

Executes an URL request using the POST method.

The POST method sends a request capable of changing resources on defined URL's server.

Syntax

webPost --url(String) [--headers(StringDictionary<String>)] --mediatype(WebMediaType) [--data(String)] [--text(String)] --file(String) --soapAction(String) (Numeric)=statusCode (Boolean)=success (String)=value (String)=errorMessage

Inputs

Script Designer Required AcceptedTypes Description
--url URL Required Text URL used to send the POST request.
--headers Header Optional String Dictionary<Text> Defines the request's header.
--mediatype Type of content Required WebMediaType The request's type of content. Options:
  • File
  • JSON
  • SOAP
  • Text
  • XML
  • --data Data Optional Text Parameters that refer to the request.
    --text Text Optional Text The POST request text.
    --file File path Only whenType of content is File Text File path that contains the contents of the desired request.
    --soapAction SOAP Action Only whenType of content is SOAP Text SOAP Action that should be sent in the request.

    Outputs

    Script Designer AcceptedTypes Description
    statusCode Status code Number HTTP status code, which informs what happened with the POST request.
    The return ranges from 100 to 500, meaning::
  • 100: Informational;
  • 200: Successful;
  • 300: Redirects;
  • 400: Errors in the request;
  • 500: Errors on the server.
  • success Success Boolean If the request was successfully sent, returns "True"; otherwise, returns "False".
    value Response Text HTTP response content sent from the server to the local machine.
    errorMessage Error message Text Error message from the request, if any error occurred.

    Example

    In the following example, a request using JSON is made with the POST method. In the outpuy, the response and the success are displayed.

    defVar --name success --type Boolean
    defVar --name response --type String
    webPost --url "http://httpbin.org/post" --mediatype "Json" --text "{\r\n  \"args\": {}, \r\n  \"data\": \"\", \r\n  \"files\": {}, \r\n  \"form\": {}, \r\n \"headers\": {\n    \"Accept\": \"*/*\",\n    \"Accept-Encoding\": \"gzip, deflate, br\",\n    \"Accept-Language\": \"en-US,en;q=0.9\",\n    \"Content-Length\": \"0\",\n    \"Content-Type\": \"application/x-www-form-urlencoded\",\n    \"Host\": \"httpbin.org\",\n    \"Origin\": \"https://resttesttest.com\",\n    \"Referer\": \"https://resttesttest.com/\",\n    \"Sec-Fetch-Dest\": \"empty\",\n    \"Sec-Fetch-Mode\": \"cors\",\n    \"Sec-Fetch-Site\": \"cross-site\",\n    \"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36\",\n    \"X-Amzn-Trace-Id\": \"Root=1-5ede73f1-2ec958e83796ef78b14edcf8\"\n  },\r\n  \"json\": null, \r\n  \"origin\": \"177.103.138.14\", \r\n  \"url\": \"https://httpbin.org/post\"\r\n}" success=success response=value
    logMessage --message "Request success: ${success}\r\nResponse: ${response}" --type "Info"
    

    Remarks

    This comand is obsolete, use the HTTP Request command instead.