Using the Multipart/form-data with binary data option

Table of contents

  • Introduction
  • Guide

Introduction

When files like images are uploaded to an API often a multipart/form-data request is required. Users can configure an HTTP client to use a “Plain” request body and configure the request themselves using hard-coded headers, and placeholders to select the binary data.

However, the placeholders use JMESPath to select the data. Depending on the binary data this can sometimes fail because JMESPath can’t handle the binary data correctly.

That’s why this guide helps you build an HTTP request using the multipart/form-data option.

Guide

Step 1: Create an Entity transformer and select the “Data, transform data using mappers and conditions” option.

Step 2: Add an HTTP Transformer to the Data transformers.

Step 3: Fill out settings:

  • Request URI;
  • Request Method - should be POST;
  • Payload type - select the “Multipart/form-data” option;
  • Add value - select type “Text” and fill out Key and Value and the content type should be “text/plain”;
  • Add value - select “File” and add extra information:
    • Key;
    • Value - add &{binaryData} in the field;
    • Type - “File”;
    • Filename - enter the name of the file;
    • Content type - should be “images/jpeg”.
    • Enable the “Base64 decode value” checkbox.

      Step 4: Execute transformer.