web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Custom API to file upload
Power Automate
Unanswered

Custom API to file upload

(0) ShareShare
ReportReport
Posted on by 20

Hi,

 

I have been playing with the Microsoft Flow for a few days to implement one of our business sceneario.

 

We have cloud solution something that manages documents. Something similar to Google Drive/Dropbox

 

What i am trying to demonstrate is when a new file is created in Sharepoint(Office 365), i want that file to be upload into our application. In order to do that we created custom api with the following swagger definition. Unfortunately i am not able to get it working

 

I compared the input messages between our custom api flow and dropbox flow. Both of them differs

 

In Dropbox i see as follows

 
 

Screen Shot 2017-01-27 at 12.30.23.png

And in our custom api i see as follows

Screen Shot 2017-01-27 at 12.29.29.png

 

Now my question is what should be swagger definition for file upload. Currently my swagger definition for the service looks like as follows

 

 

/{community_id}/rooms/{room_id}/content/{id}/children:
 post:
 operationId: uploadFile
 summary: Upload single file to folder
 description: |
 The single file upload endpoint çreates file in folder.
 The response includes status and meta info about created file.
 security:
 - OauthSecurity: []
 consumes:
 - application/octet-stream # and/or application/x-www-form-urlencoded
 parameters:
 - $ref: "#/parameters/community_id"
 - $ref: "#/parameters/room_id"
 - $ref: "#/parameters/id"
 - name: file
 in: body
 description: Uploaded file data
 required: true
 schema:
 $ref: '#/definitions/File'
 
 tags:
 - Upload file
 responses:
 '200':
 description: File is succesfully uploaded
 '400':
 $ref: "#/responses/ValidationError"
 '401':
 $ref: "#/responses/AuthenticationError"
 '403':
 $ref: "#/responses/AuthorizationError"
 '404':
 $ref: "#/responses/NotFoundError"
 '500':
 $ref: "#/responses/UnexpectedError"

definitions:

 File:
 description: The file object
 type: object
 properties:
 name: 
 description: Name of file
 type: string
 file: 
 description: File content
 type: string
Categories:
I have the same question (0)
  • JS-27041152-0 Profile Picture
    on at

    You didnt mention how your API works.  The swagger definition will depend on how your custom API works, rather than making it similar to that of Dropbox.

     

    Specifically, it looks like your API is expecting a JSON payload with two fields: "name" and "file", which is a string.  If you are trying to transfer a binary file into a JSON string, you must encode it.  You can use base64 encoding, and your API will have to decode it.  In that case, you will use an additional property called "format" with the value "byte".

     

          file:
            description: File content
            type: string

            format: byte

     

    The Dropbox Connector, OTOH does things slightly different.  It takes the filename as a query parameter and takes the binary blob of the file content in the request payload.  A format of 'binary' is used to describe that (although there is a debate that it may not be the correct interpretation).

     

     

  • ayyz Profile Picture
    20 on at

    Thank you very much for the speedy reply

     

    Ideally i want the REST service to accept multipart data. We tried various configuration but unfortunately it always throws error while creating the CustomAPI connection in PowerApps. Could you please provide me a sample swagger definition for the same

     

    Cheers

     

    Ayyanar.M

  • JS-27041152-0 Profile Picture
    on at

    Unfortunately, multipart data doesnt work today.  It is a limitation that we plan to address in future.  When it works, we will use "formData" as defined in the open api/swagger spec.

     

  • ayyz Profile Picture
    20 on at

    In that case do u think the following is good enough

     

    /{community_id}/rooms/{room_id}/content/{id}/children:
     post:
     operationId: uploadFile
     summary: Upload single file to folder
     description: |
     The single file upload endpoint çreates file in folder.
     The response includes status and meta info about created file.
     security:
     - OauthSecurity: []
     consumes:
     - application/json # and/or application/x-www-form-urlencoded
     parameters:
     - $ref: "#/parameters/community_id"
     - $ref: "#/parameters/room_id"
     - $ref: "#/parameters/id"
     - name: file
     in: body
     description: Uploaded file data
     required: true
     schema:
     $ref: '#/definitions/File'
     
     tags:
     - Upload file
     responses:
     '200':
     description: File is succesfully uploaded
     '400':
     $ref: "#/responses/ValidationError"
     '401':
     $ref: "#/responses/AuthenticationError"
     '403':
     $ref: "#/responses/AuthorizationError"
     '404':
     $ref: "#/responses/NotFoundError"
     '500':
     $ref: "#/responses/UnexpectedError"
    
    definitions:
    
     File:
     description: The file object
     type: object
     properties:
     name: 
     description: Name of file
     type: string
     file: 
     description: File content
     type: string
     format: byte
  • Fvamaro Profile Picture
    45 on at

    Hi @ayyz,

    (I'm having some issues with a project similar to yours, can you help me?)

     

    I'm integrating a personal App(asp.Net) with Microsoft Flow.
    One of the main goals is to have a Custom connector that can send/receive files from my app storage(Azure storage) to the Microsoft applications (OneDrive, outlook, etc) using Microsoft flow.
    However I'm getting some issues manipulating Files.

    Let me show you an example:

    Flow.PNG

     

    In this Flow when an email is flagged I must save the attachment in my app storage.

     

     

     

     

     

     

     

     

     

     

     

     

     

    Doc_Content : The attachment content;
    Cont_ID : The azure container where the file will be save;
    Doc_Name : Attachment Name;

     

     

     

     

     

     

     

     

    And I receive the parameters like this:Containers OP.PNG

     

     

     

     

     

     

     

     

    Doc_Content is a string because I think that 'Content' its a string base64 (am I rigth?)

    I need to know how can I receive and send files between my App and Flow( connectors):
        ->Whats the type of 'Content'? How can I use it to get a byte[]?

     

     

    Best reagrds,

    Filipe Amaro

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 382

#2
Valantis Profile Picture

Valantis 370

#3
David_MA Profile Picture

David_MA 300 Super User 2026 Season 1

Last 30 days Overall leaderboard