Skip to main content

URI.post

postbodymethodheadersresponse_format

Group: Output
Aliases: http post, upload

Documentation

Writes the provided data to the provided URI. Returns the response, parsing the body if the content-type is recognised. Returns an error if the status code does not represent a successful response.

Arguments

  • body: The data to write. See Supported Body Types below.
  • method: The HTTP method to use. Must be one of HTTP_Method.Post, HTTP_Method.Put, HTTP_Method.Patch. Defaults to HTTP_Method.Post.
  • headers: The headers to send with the request. Defaults to an empty vector.
  • response_format: The format to use for interpreting the response. Defaults to Auto_Detect. If Raw_Response is selected or if the format cannot be determined automatically, a raw HTTP Response will be returned.

Remarks

Specifying Content Types

If the body parameter specifies an explicit content type, then it is an error to also specify additional Content-Type headers in the headers parameter. (It is not an error to specify multiple Content-Type values in headers, however.)

Supported Body Types

  • Request_Body.Text: Sends a text string, with optional encoding and content type.
  • Request_Body.Json: Sends an Enso object, after converting it to JSON.
  • Request_Body.Binary: Sends a file.
  • Request_Body.Form_Data: Sends a form encoded as key/value pairs. The keys must be Text, and the values must be Text or File.
  • Request_Body.Empty: Sends an empty body.

Additionally, the following types are allowed as the body parameter:

  • Text: shorthand for Request_Body.Text that_text.
  • File: shorthand for Request_Body.Binary that_file.
  • Any other Enso object: shorthand for Request_Body.Json that_object.