Search code examples
jsonazuremultipartform-dataazure-logic-apps

Azure Logic Apps - multipart/form-data failing


I'm trying to set up a Logic App that will post data to an AWS Bucket (Link) accepting content formatted as multipart/form-data. However, I'm not able to get a successful request running and only get some form of error that seems to be related to the multipart structure.

Error: <Error><Code>IncompleteBody</Code><Message>The request body terminated unexpectedly</Message

When catching the request in Beeceptor to compare the request from Logic Apps with a standard HTTP call from a REST Client I can see that both bodies are identical but the headers differ. Logic Apps adds a lot of tracking info but also seems to send a differing Content-Length.

VS Code REST Client request (working correctly):

{
  "content-length": "2425",
  "user-agent": "vscode-restclient",
  "content-type": "multipart/form-data; boundary=formBoundary",
  "accept-encoding": "gzip, deflate"
}

Logic Apps request:

{
  "content-length": "2384",
  "accept-language": "en-US",
  "user-agent": "azure-logic-apps/1.0 (workflow <redacted>; version <redacted>)",
  "x-ms-workflow-id": "<redacted>",
  "x-ms-workflow-version": "<redacted>",
  "x-ms-workflow-name": "<redacted>",
  "x-ms-workflow-system-id": "/scaleunits/prod-00/workflows/<redacted>",
  "x-ms-workflow-run-id": "<redacted>",
  "x-ms-workflow-run-tracking-id": "<redacted>",
  "x-ms-workflow-operation-name": "Import_File",
  "x-ms-tracking-id": "<redacted>",
  "x-ms-correlation-id": "<redacted>",
  "x-ms-client-request-id": "<redacted>",
  "x-ms-client-tracking-id": "<redacted>",
  "x-ms-action-tracking-id": "<redacted>",
  "x-ms-activity-vector": "IN.02",
  "traceparent": "<redacted>",
  "accept-encoding": "gzip, deflate",
  "content-type": "multipart/form-data; boundary=formBoundary"
}

Any ideas on how to fix this?


Solution

  • Apparently the issues were related to how the multipart-form data was formatted and added to the HTTP-request step. I started with the following format:

    Source: https://medium.com/@devanshijoshi/post-multipart-form-data-using-azure-logic-apps-8902ab1d7c4e

    When changing it to the following format it started working (as suggested in MSFT docs):

    enter image description here

    The documentation is quite scarce on this and the error codes do not really direct you in any relevant direction unfortunately, hopefully this helps someone else.