Multipart form

Multipart form request is typically used to send large files and data to a server.

This request format can be declared in any blocks (execute, acquire, fields etc.) in your custom adapter code. It should be chained to one of the base request.


Let's use the Convert document endpoint in IBM Watson API as an example. This endpoint accepts a document in multipart/form-data format.

A cURL example looks like this:

curl \ \
  -X POST \
  -u "{username}":"{password}" \
  -F config="{\"conversion_target\":\"answer_units\"}" \
  -F "file=@sample.pdf;type=application/pdf"


  title: "IBM Watson",

  connection: {...},

  actions: {
    upload_file: {
      input_fields: lambda do
          { name: "file_name", type: "string" },
          { name: "file_data", type: "string" },
          { name: "conversion_target", type: "string" }

      execute: lambda do |connection, input|
          params(version: "2015-12-15").
          payload(file: [input['file_data'], 'application/pdf'],
                  file_name: input['file_name'],
                  config: "{\"conversion_target\":\"#{input['conversion_target']}\"}")

    output_fields: {...}

In the SDK, notice that the file key in the payload takes an array of length 2. This defines the request as form data. The first item in the array is the file data and the second item is the media type (MIME type) of the input file.


cURL Workato
curl -X POST post("")
.params(version: "2015-12-15")
-u "{username}":"{password}" This is defined in the [connection](../authentication/ block and is automatically added onto the outgoing request.
-F config="{\"conversion_target\":\"answer_units\"}"
-F "file=@sample.pdf;type=application/pdf"
    file: [input['file_data'], 'application/pdf'],
    file_name: input['file_name'],
    config: "{\"conversion_target\":\"#{input['conversion_target']}\"}")

results matching ""

    No results matching ""