How to: Make a Multipart API Call in Unqork

Prev Next

Making a multipart API call in Unqork requires a Plug-In component like other API calls, but you'll also use a Calculator component to define the MIME Types (Multipurpose Internet Mail Extensions) included in your request. Let's look at a common example of sending a Base64 encoded PDF in a POST call.

You do not need to use multipart API calls for Unqork services. This example shows the steps you’d follow once you’ve set up an integration that requires a multipart API call. Meaning, this guide is only an example and you cannot perform this call in Express View.

These instructions assume you have a new module open, saved, and with a title.

Configuration

Select the tab that corresponds to your Unqork Designer experience:

Configure the Hidden Components

The first two Hidden components will store the PDF MIME Type and the Base64 encoding for the PDF. Later, you’ll set up a Calculator component to combine them.

  1. In the Module Builder, drag and drop the first Hidden component onto your canvas.

  2. In the Property ID  and Label Text fields, enter base64OfFile.

  3. Click Save Component.

  4. Drag and drop a second Hidden component onto your canvas, placing it below the first Hidden component.

  5. In the Property ID  and Label Text fields, enter mimeType.

  6. In the Default Value field, enter application/pdf.

    In this case, our MIME type is a PDF. You’ll replace application/pdf with whatever MIME type you’re using.

  7. Click Save Component.

Configure the Calculator Component

This Calculator component combines the values from your first two Hidden components in the encodedFileURI you’ll add in the next step.

  1. Drag and drop a Calculator component onto your canvas, placing it below your Hidden components.

  2. In the Property ID and Label Text fields, enter calcMimeType.

  3. In the Inputs table, enter the following:

    #

    Source

    Alias

    Required

    1

    base64OfFile

    pdf

    (checked)

    2

    mimeType

    mime

    (checked)

  4. In the Outputs table, enter the following:

    #

    Source

    Formula

    1

    encodeFileURI

    =CONCATENATE('data:',mime,';base64,',pdf)

    Calculator settings with Inputs and Outputs tables highlighted.

  5. Click Save Component.

Configure the Hidden Component

The third Hidden component in this configuration serves as the output for the Calculator component.

  1. Drag and drop a Hidden component onto your canvas, placing it below your Calculator component.

  2. In the Property ID  and Label Text fields, enter encodedFileURI.

  3. Click Save Component.

Configure the Plug-In Component

This Plug-In component handles the API call. Here, you'll specify that you're making a multipart API call. Again, these instructions assume that you've already set up an API in Services Administration. In the following steps, you'll select that API from the Services drop-down.

  1. Drag and drop a Plug-In component onto your canvas, placing it below your encodedFileURI Hidden component.

  2. In the Property ID  and Canvas Label Text fields, enter pluginMultipartApiCall.

  3. From the Internal Services drop-down, select your API. Ensure the Request Type is set to POST.

  4. Set Make a Multipart API Call to (ON).

    A box displays letting you enter an Alternative Multipart Sub-Type. If your API requires a type other than multipart/form-data, enter it here.

  5. In the Inputs table, enter the following:

    Property ID

    Mapping

    Required

    encodedFileURI

    file

    (checked)

    Plug-In component settings with Request Type, Make a multipart API call and the Inputs table highlighted.

  6. Click Save Component.

Configure the Button Component

The Button component trigger your Plug-In component when clicked, ultimately executing the API call.

  1. Drag and drop a Button component onto your canvas, placing it below your Plug-In component.

  2. In the Property ID field, enter btnsubmitMultipartCall.

  3. In the Label Text field, enter Submit Multipart Call.

  4. From the Action Type drop-down, select Event.

  5. From the On Click drop-down, select pluginMultipartApiCall.

    Button component settings with Action Type and On Click fields highlighted.

  6. Click Save Component.

  7. Save your module.

Configure the Hidden Components

The first two Hidden components will store the PDF MIME Type and the Base64 encoding for the PDF. Later, you’ll set up a Calculator component to combine them.

  1. In the Module Builder, drag and drop the first Hidden component onto your canvas.

  2. In the Property ID  and Label Text fields, enter base64OfFile.

  3. Click Save.

  4. Drag and drop a second Hidden component onto your canvas, placing it below the first Hidden component.

  5. In the Property ID  and Label Text fields, enter mimeType.

  6. In the Default Value field, enter application/pdf.

    In this case, our MIME type is a PDF. You’ll replace application/pdf with whatever MIME type you’re using.

  7. Click Save.

Configure the Calculator Component

This Calculator component combines the values from your first two Hidden components in the encodedFileURI you’ll add in the next step.

  1. Drag and drop a Calculator component onto your canvas, placing it below your Hidden components.

  2. In the Property ID  and Label Text fields, enter calcMimeType.

  3. In the Inputs table, enter the following:

    #

    Property ID

    Alias

    Required

    1

    base64OfFile

    pdf

    (checked)

    2

    mimeType

    mime

    (checked)

  4. In the Outputs table, enter the following:

    #

    Property ID

    Formula

    1

    encodeFileURI

    =CONCATENATE('data:',mime,';base64,',pdf)

    Calculator component settings with Inputs and Outputs tables highlighted.

  5. Click Save & Close.

Configure the Hidden Component

The third Hidden component in this configuration serves as the output for the Calculator component.

  1. Drag and drop a Hidden component onto your canvas, placing it below your Calculator component.

  2. In the Property ID  and Label Text fields, enter encodedFileURI.

  3. Click Save.

Configure the Plug-In Component

This Plug-In component handles the API call. Here, you'll specify that you're making a multipart API call. Again, these instructions assume that you've already set up an API in Services Administration. In the following steps, you'll select that API from the Services drop-down.

  1. Drag and drop a Plug-In component onto your canvas, placing it below your encodedFileURI Hidden component.

  2. In the Property ID  and Canvas Label Text fields, enter pluginMultipartApiCall.

  3. From the Internal Services drop-down, select your API. The Data Source URL automatically populates.

  4. Set the Request Type as POST.

  5. Set Make a Multipart API Call to (ON).

    A box appears letting you enter an Alternative Multipart Sub-Type. If your API requires a type other than multipart/form-data, enter it here.

  6. In the Inputs table, enter the following:

    Property ID

    Mapping

    Required

    encodedFileURI

    file

    (checked)

    Plug-in component settings with settings highlighted.

    Plug-in component settings with Inputs table and Trigger Type highlighted.

  7. Click Save.

Configure the Button Component

The Button component triggers your Plug-In component when clicked, ultimately executing the API call.

  1. Drag and drop a Button component onto your canvas, placing it below your Plug-In component.

  2. In the Property ID field, enter btnsubmitMultipartCall.

  3. In the Label Text field, enter Submit Multipart Call.

  4. Setthe Action Type as Event.

  5. From the On Click drop-down, select pluginMultipartApiCall.

    Button component settings with Action Type and On Click highlighted.

  6. Click Save & Close.

  7. Save your module.