web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details
Power Automate - Building Flows
Answered

Post File via HTTP

Like (1) ShareShare
ReportReport
Posted on 2 Mar 2017 19:48:58 by 21

I am trying to identify a method to use flow to send the attachment of an email via HTTP Post to a custom API. This API accepts multipart form data with file attachments and works when testing via PostMan. However, when trying to craft together the Flow steps I am unable to emulate the request. 

 

Is there any way to do this type of request via Flow and a custom API?

 

My Setup

Step 1) When an email is flagged. 

Step 2) For each attachment:

   A) HTTP

            Method: POST

            URL: Custom API URL

            Header: { "Content-Type": "application/x-www-form-urlencoded" }

            Body: [attachments]

            Authentication: None

  

When the API recieves the request, it appears to be the encoded file but not in a multipart form request. I have full control over how the API handles the request data so could go about this a different way, but I'm completely stuck with figuring out how the Body field is supposed to behave with an attachment. 

I have the same question (0)
  • Verified answer
    jjurisch Profile Picture
    21 on 02 Mar 2017 at 22:13:09
    Re: Post File via HTTP

    I was able to finally self solve this with some more advanced trial and error. Hopefully it will help somebody else down the line until there is better documentation around the actions. 

     

    It turns out that if you add the [attachments] object to the body of the email it will submit a JSON array with attributes of the file and the file itself encoded in Base64. So I just needed to update my API handler to accept a JSON array, loop through each attachment and decode the ContentBytes into a file again. 

     

    I didn't experiment with adding additional attachment information to the body, but my use didn't need anything else from the message. 

     

    Example Attachment Record

    [{
     "Id": "AQMkADgxZmMyZmVmLWZiYTEtNGI3ZC05NzZlLTUzYTM1MGQ0YjdmNgBGAAAD5GChXHSojUuPkBPyKc4QiwcAZAodtTo4mUerxYfYMVtIcwAAAgEMAAAAZAodtTo4mUerxYfYMVtIcwAB6K4I0AAAAAESABAAszVi_Bwy20yVhdzX_og1fA==",
     "ContentType": "application/zip",
     "Size": 12552,
     "@odata.type": "#Microsoft.OutlookServices.FileAttachment",
     "Name": "attachment.zip",
     "ContentBytes": "UEsDBAoAAAAIAK1RT0odhQmifC4AAGhABgAyAAAAZ29vZ2xlLmNvbSFlbmdhZ2UuM20uY29tITE0ODcwMzA0MDAhMTQ4NzExNjc5OS54bWztnduO20iWru/7KQp9n2FGkMETPJ49wMz0xQZmgJ4e7MsCRVISKylSICm7VE+/I6hDMm01My2RGYtRP2C5XHmQKOnTinX81+d//X1X/vI1b9qirv7lr5w5f/0lr9I6K6rNv/z1f//xn0/hX3/51y9/+bzO82yVpM9f/vLLL5+bfF833a+7vEuypEv019RX62bza5Xs8i+but6UOUvr3edP1y+efibfJUX5parVPZTHp2yXNOlTe9jru/s/w187/dz5d37vmuTXtK66JO1+Lap1/WXbdfs2/vTp/Kvs5Vc/JZ+Sqv2WN5+E5/sydNR9/fj7pzs+P40i++IKTwoZisAJXBmJIIzU7718+/Tj6qnmvzZJtTk/GfWlVb4pqi/cCwPHdTxH/dLpK5fv51XWf5dzP4gidSnV5c4+vb6366MNX9PP+7os0uOv+8OqLNptfr2QWr061Ze82iSbnLm700t2/urpR5Lsudh9aT5/Ov3j/MV2v+6/pv97+tJevRdV/vnT/vz/7eUL7eUr+7T7wvUz0//or/TWVanXMq2bywU29bfrS9DWhybNfy32X4Tj8FjKMF7n3I95FEfqb+7FXKqbH6rHvP7o5ZfT+lCph//86fSPy5fPV5B/TcqDehmzyzf0a1O0+7otOoXz+ZkMvzL4Of2y7JO2VT9wfYXOL8H6y1rRp1+D9fUhP91+TPW+XZ7r5yLLq65YF+rDdP21bZ5kefPruql3379fw2+d7+uHe/icHLrtr03eHsru5U6/u+C3cTjTru/l/JzP/zN41nmZp13dfMmeuSO8J+FwoV6By1evL8PwsT8PXqCfvo62Xnenl/n1tQxedkXqd09f//CFs3ch5ztBvA5XTqw+nCJOHRnHQiRAzQ7UNvqU+PlrmBYxJ2Scu0xZN8ZF8M/RcoHWgtCiZMUCj2
    },]

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 655 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 371 Moderator

#3
chiaraalina Profile Picture

chiaraalina 276

Last 30 days Overall leaderboard
Loading complete