REST Output Multipart Form-Data Request

Multipart Form-Data Requests

A multipart form-data request looks like the following:

POST / HTTP/1.1
[[ Less interesting headers ... ]]
Content-Type: multipart/form-data; boundary=---------------------------735323031399963166993862150
Content-Length: 834

-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="text1"

text default
-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="text2"

aωb
-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="file1"; filename="a.txt"
Content-Type: text/plain

Content of a.txt.

-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="file2"; filename="a.html"
Content-Type: text/html

<!DOCTYPE html><title>Content of a.html.</title>

-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="file3"; filename="binary"
Content-Type: application/octet-stream

aωb
-----------------------------735323031399963166993862150--

It consist of a typical Content-Type header (Content-Type: multipart/form-data; ...) and parts.

Parts look like the following:

-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="text1"

text default
-----------------------------735323031399963166993862150
Content-Disposition: form-data; name="file1"; filename="a.txt"
Content-Type: text/plain

Content of a.txt.

A part has a name (file1), filename (a.txt), content-type (text/plain), and the file contents.

Multipart Form-Data REST Field Configuration

This section describes the part of creating a REST Output when the request type is set to Multipart.

  1. Enter an endpoint.

    • Shown on the the REST Connection form, the final request URL is the concatenation of the base URL from the REST Connection and endpoint. The base URL can (but isn't required to) have an ending slash character. Similarly, the endpoint can (but isn't required to) have a starting slash character. Hero_Flow can handle it.
    • If the full URL of the endpoint is https://domain.com:12/api/v2/issues and if the base URL contains https://domain.com:12/api/ the endpoint field's value can be either /v2/issues or v2/issues.
    • Some endpoints require the use of path parameters. This means the endpoint path has path segments that vary request by request.
      • For example, when updating ticket 123 from project PROJECT1, the request should be sent to https://domain.com:12/api/v2/project/PROJECT1/issue/123 for updating ticket 456 from the same project. The request should be sent to: https://domain.com:12/api/v2/project/PROJECT1/issue/456. 
        If the base URL contains https://domain.com:12/api/v2/ , the endpoint value should be /project/${project}/issue/${issue}. Fields appear for project and issue in the field mapping table below. These parameters will be resolved before each HTTP request from the actual tuple. Of course, if project is always the same for the Output, it is possible to use /project/PROJECT1/issue/${issue} and have only field mapping for issue.

  2. Enter additional request headers, query parameters, and/or cookie parameters with their values.

    • These parameters are merged with the Connection parameters. If a parameter is set on both forms, the Output's value overrides the value from the Connection.

    • The terms "Header", "Query" and "Cookie" parameters are HTTP terms that reflect the location of the parameter in the HTTP request. The API documentation states the exact location and the name of the required and the optional parameters. 

    • Header and cookie parameters are generally used for authentication/authorization or sending preferred language, location, response format, etc.


  3. Add as many parts as needed. For every part:

    1. the name should the the desired part name by the API provider.
    2. the type can be either STRING (for values) or BINARY (for files).
  4. The input mapping table is generated by variables used in the endpoint, header, query parameters, and cookie parameters.
  5. The input mapping table is also generated for the desired parts:
    1. for each STRING part, one value field (allows null in the flow execution).
    2. for each BINARY part, 3 fields:
      1. mime - (allows null in the Flow execution, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types )
      2. file name - (allows null in the Flow execution)
      3. value (binary, allows null in the Flow execution)
  6. Click OK to save the Output configuration.