Skip to main content

Upload a file to an update using power automate

  • April 10, 2024
  • 6 replies
  • 679 views

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

6 replies

  • New Participant
  • April 22, 2024

+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.


dipro
Forum|alt.badge.img
  • Leader
  • April 22, 2024

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…


  • New Participant
  • April 23, 2024

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?


dipro
Forum|alt.badge.img
  • Leader
  • April 23, 2024

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!


  • New Participant
  • April 26, 2024

Wow you are a lifesaver. It works perfectly!

Thank you so much for your help 🙌


dipro
Forum|alt.badge.img
  • Leader
  • June 12, 2024