Upload a file to an update using power automate

I am struggling to upload a file to an update using power automate. I have managed using postman but I am unable to replicate it.
I would like to upload a file using a url and this is the query I am using:

image

2 Likes

+1 on this! Found several solutions on this but it’s not working on my end. The best one that I found is this, except the example uses BambooHR instead of Monday, and I have no idea on how to include the mutation into the request body.

1 Like

Our API does not support uploading a file from a URL. You will have to upload the content of the file instead. Not sure if PowerAutomate supports that…

Thanks for the reply Dipro! Power Automate does indeed support uploading file content instead of the URL.

This is the multipart request that I’ve added in the HTTP body:

{
  "$content-type": "multipart/form-data",
  "$multipart": [
    {
      "body": "3088397636",
      "headers": {
        "Content-Disposition": "form-data; name=\"update_id\""
      }
    },
    {
      "body": "iVBORw0KGgo ...",
      "headers": {
        "Content-Disposition": "form-data; name=\"file\"; filename=\"test blue_logo.png\""
      }
    }
  ]
}

Are there any other perimeters that I need to include in the body?

Aha, thanks for clarifying. I also read the article you linked and am starting to understand how PowerAutomate converts this JSON into a valid multipart.

For our API, you need to have three parts in the multipart:

  • query: your query
  • map: maps the relation between variables in your query and other parts of the request
  • one or more variables: these are referenced by name in the map (example below)

In PowerAutomate JSON format, it would look somehting like this:

{
  "$content-type": "multipart/form-data",
  "$multipart": [
    {
      "body": "mutation ($file: File!) { add_file_to_update (file: $file, update_id: 1234567890) { id } }",
      "headers": {
        "Content-Disposition": "form-data; name=\"query\""
      }
    },
    {
      "body": "{\"image\":\"variables.file\"}",
      "headers": {
        "Content-Disposition": "form-data; name=\"map\""
      }
    },
    {
      "body": "iVBORw0KGgo ...",
      "headers": {
        "Content-Disposition": "form-data; name=\"image\"; filename=\"test blue_logo.png\"",
        "Content-Type": "<Content-Type header here>"
      }
    }
  ]
}

I copied the content of each part from our Postman sample collection – Upload a file to an update

Hope this helps!

2 Likes

Wow you are a lifesaver. It works perfectly!

Thank you so much for your help :raised_hands:

2 Likes

A post was split to a new topic: 500 error when uploading file to update using PowerAutomate