Forum Discussion

Cyberturnip's avatar
Cyberturnip
New Contributor
12 months ago

Posting a file to an API using Power Automate

I can use Swagger to post a file to a folder in my system using swagger but I want to be able to do this in Power Automate

The curl response is 

curl -X 'POST' \  'https://siteURL/api/1/files/content?parentfolderid=43618' \  -H 'accept: application/json' \  -H 'Content-Type: multipart/form-data' \  -F 'file=@car.txt;type=text/plain' \  -F 'filename=Car'

How do I convert this to Power Automate? I know I need to use multipart form data, but I have no idea how to configure this and none of the "solutions" that I have seen posted online work.
I am tearing what little hair out trying to resolve this but I'm shooting in the dark - I am not a programmer. Merely an enthusiastic amateur
Thanks

 

1 Reply

  • So by way of update, I can now post txt files, but other formats do not go through and look corrupt
    The body of the http post in Power Automate is:

     

    ------Boundary123
    Content-Disposition: form-data; name="file"; filename="@{items('Apply_to_each')?['Path']}"
    Content-Type: @{items('Apply_to_each')?['MediaType']}

    @{outputs('Compose')}
    ------Boundary123
    Content-Disposition: form-data; name="filename"

    @{items('Apply_to_each')?['NameNoExt']}
    ------Boundary123--