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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Custom connector to up...
Power Automate
Unanswered

Custom connector to upload a file via HTTP to a REST API

(1) ShareShare
ReportReport
Posted on by 57

I have been able to use the following HTTP request in a Logic App to upload a file to a REST API without any issues.  I am trying to add it to my custom connector for this API though, and haven't been able to sort it out.  Can anyone give me any pointers? 

 

6.png

Categories:
I have the same question (0)
  • Gareth1 Profile Picture
    308 on at

    Hi @wstock 

    Have you tried wrapping the file content in base64ToString() before passing it to the HTTP request?

     

     

  • v-alzhan-msft Profile Picture
    on at

    Hi @wstock ,

     

    Could you please share more details about the custom connector?

     

    Best regards,

    Alice       

     

    Community Support Team _ Alice Zhang
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

  • wstock Profile Picture
    57 on at
    Sure, I have a custom connector that connects to the API through a while different bunch of endpoints methods. Everything is working fine. Trying to add in the ability to upload a file using an http POST request. The example screenshot I included above is WORKING in a logic app fine. I am trying to duplicate the behavior in my custom connector.
  • wstock Profile Picture
    57 on at

    @Gareth1 , the HTTP request in my screenshot works fine.  It is the custom connnector I am having trouble with...are you meaning wrap the filecontent in the base64ToString() inside the custom connector? 

     

  • wstock Profile Picture
    57 on at

    @v-alzhan-msft Here is some more info on the connector:

     

    I created this specific piece of the connector using the "import from sample" option (the rest was created from importing a Postman collection.)  I pasted in the BODY of the HTTP request that I posted above, and configured the URL and PARAMETERS as necessary.  I think I'm at least half way there, but I feel like I'm missing something with the body.  Here is what it looks like so far: 

     

    "The Connector"

    The ConnectorThe Connector

     

    "The Connector BODY"

    Contents of the "BODY"Contents of the "BODY"

     

    What it looks like in a LOGIC APP

    What it looks like in a logic APP.What it looks like in a logic APP.

     

    And finally, here is the relevant Swagger piece:

    /Web/api/QMS/UserCertificates/UploadFile:
     post:
     summary: UploadFile
     description: 'Attach a file to an existing QMS User Certificates. Valid file
     types: PDF, Image (.jpg, .png) If the UserCertificateID != -1 then this UserCertificateID
     will be used to find the existing UserCertificate Otherwise the UserCertificateGUID
     will be used to find the existing UserCertificate'
     operationId: UploadFile
     parameters:
     - {name: UserCertificateID, in: query, required: true, type: string}
     - {name: AccountLoginName, in: header, required: true, type: string}
     - {name: AccountPassword, in: header, required: true, type: string}
     - {name: SourceSystemID, in: header, required: true, type: string, default: 'PALCC'}
     - {name: DomainID, in: header, required: true, type: string, default: 'PALCC'}
     - name: body
     in: body
     required: true
     schema:
     type: object
     properties:
     $content-type: {type: string, description: $content-type, title: '', default: '"multipart/form-data",'}
     $multipart:
     type: array
     items:
     type: object
     properties:
     body: {type: string, description: body}
     headers:
     type: object
     properties:
     Content-Disposition: {type: string, description: Content-Disposition,
     title: '', default: '"form-data; name=\"file\"; filename="'}
     description: headers
     description: $multipart
     x-ms-visibility: important
     x-ms-visibility: important
     responses:
     default:
     description: default
     schema: {}
     x-ms-visibility: important
  • Gareth1 Profile Picture
    308 on at

    Hi @wstock 

    I haven't much with Custom Connectors, however if it works ok through the Logic App (and I am guessing Postman), is the API expecting the file content to be a string or in bytes. If it is a string in the flow you could wrap the file content in a base64tostring expression

    6.png

  • wstock Profile Picture
    57 on at
    I don't have a problem with this HTTP POST request. It works fine. I want to implement it as a custom connector vs. the HTTP connector. So, not sure if wrapping it in that base64tostring expression is the way to go. Can you even do that in a custom connector?
  • Community Power Platform Member Profile Picture
    on at

    Did you solve the problem? I'm stuck with the same problem ! 

  • Cam Profile Picture
    185 on at

    I'm also stuck with this issue.

    i have the same scenario - i've got a successful HTTP action to upload a Binary file to an API,

    now i'm trying to convert it to a custom connector.

     

    here is my HTTP action

    Cam_0-1654131097813.png

     

     

    i made a custom connector, that mimic's the HTTP action.

    but, it is a bit too difficult for end-users to need to write all this fluff - i would like it to be simpler.

    Cam_1-1654131142060.png

     

    here is what they were talking about above, with the Base64toBinary() function

    Cam_2-1654131409224.png

    this is the UploadFile on the trigger

    Cam_3-1654131832803.png

     

    this is the (first) body on the Upload BevChain Stock Damage Photo action

    Cam_4-1654131881406.png

     

     

     

     

    i really like what you've done in your Logic App.
    that looks a lot easier for end-users to use.
    i'm going to give this a go and see if i can do this in the Power Platform custom connector too 🙂

    Cam_5-1654131959544.png

     

  • Cam Profile Picture
    185 on at

    did you ever work out the body section?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard