Navigation

post

Definition

post

Corresponds to HTTP method POST.

Important

For an HTTP Service, you must have rules set up for the action.

The post action stage has the following syntax:

Tip

In the stages, the action arguments can make use of variables (%%vars) defined for the stage as well as defined constants and expansions.

{ "service": <http-servicename>, "post": "head", "args": { url: <url>, ... } }

The post action takes the following arguments:

Argument Type Required
url string The URL string for the HTTP request. Alternatively, you can specify the components of the URL. See Alternative URL Arguments.
authUrl string Optional. The auth URL (i.e. URL that grants a cookie) for the HTTP request.
body string Corresponds to the body of the HTTP request. For form content, see Include multipart/form-data Content in a Request.
headers array of strings Optional. Corresponds to the HTTP header fields and the corresponding values are an array of values (e.g. "Content-Type": [ "application/json" ]) for the request.
cookies string Optional. Cookie name and value pairs.
followRedirects boolean Optional. Determines whether or not to follow redirects.

Note

If the HTTP response has a JSON body (Content-Type: application/json), the output of the stage is the parsed JSON body, which can be treated as a document in downstream stages.

Alternative URL Arguments

As an alternative to passing the url argument as a single string, you can instead specify the individual components of the url string.

Note

The following HTTP action arguments and the url argument are mutually exclusive. Use one or the other, but not both.

If you use the following arguments instead of the url argument, the scheme and host fields are required.

Name Contents
scheme Required. Defaults to https. Permissible values are https and http.
host Required. The hostname for the request. In the URL https://mongodb.example.net/api/v1.0/entity, the hostname is mongodb.example.net.
path The path portion of the URL. In https://mongodb.example.net/api/v1.0/entity, the path portion is /api/v1.0/entity.
query

Document containing keys and values which map to the URL’s query string. Each key must be a string and each value must be an array of strings, even if the array contains only one element. For example, given the query document:

{ "x": ["hello"], "y": ["world"] }

The query is appended to the outgoing request as ?x=hello&y=world.

If an array contains more than one element, all the elements are included with the same key. For example, given the query document:

{ "cars": ["Porsche", "Audi"], "bikes": ["Trek", "Marin"] }

The query is appended to the outgoing request as ?cars=Porsche&cars=Audi&bikes=Trek&bikes=Marin.

fragment The portion of the URL which comes after the anchor (#).
username In conjunction with the password argument, allows the action to access the given URL with basic authentication.
password See username.

Include multipart/form-data Content in a Request

If you need to include content of type multipart/form-data with your HTTP request, use the form argument instead of a body argument. The form argument takes a document in which each key is a form field, and the request is submitted with a content-type of multipart/form-data.

The following is an example of a form argument with multiple fields:

"form" : {
  "to-address" : "name@example.com",
  "from-address" : "other-name@example.com",
  "subject" : "test subject",
  "message-body" : "test message body"
}
←   patch put  →