cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FoDelement
Responsive Resident
Responsive Resident

How to send attachments using custom connector

Hello all!

I am using a custom connector to send API requests to a server. I am using an attachment box in Powerapps as a "file upload". I pass the file to flow using Shane's method here. The file uploads (in this case a PDF) but when I try to open it, it is corrupted. I can not figure out how to post the file correctly. Here is an example of it working in Postman. (using form-data)

FoDelement_0-1607037840825.png


I assume I need to define both the content type and the content? But I am not sure how to do that.

FoDelement_1-1607038076859.png


Thanks!



7 REPLIES 7
ManishJain
Solution Sage
Solution Sage

Hi @FoDelement ,

 

Is this attachment of Postman making call to your api via custom connector ?

 

Thanks

Hello @ManishJain.

It is not, I went straight into the API of the application. 

 

 

Hi @FoDelement ,

 

At the right side of the Postman below Send button there is a link to view code (Code) , you can click on it to view the request which is sent. In the pop up window that opens(Generate Code Snippets) select HTTP from the list of options at left side. The JS code you see can be used in custom connector testing as well. Not sure if the testing allows to attach file but you can run the test case in Flow.

 

Thanks

FoDelement
Responsive Resident
Responsive Resident

@ManishJain 
Thank you for this info. Below is the output. I cans see where it is getting the file name from, but it does not show how it's passing the actual data. I was hoping putting the base64 data as the body in the custom connector would work, but so far I can't get the files to open. 


POST /SM/9/rest/interactions/SD5443824/attachments HTTP/1.1
Host: SERVER:13212
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: attachment; filename=2020-10-02 16_06_00-Start.pdf
Authorization: Basic XXX=
Cookie: JSESSIONID=XXXX
Content-Length: 221

----WebKitFormBoundary7XXX
Content-Disposition: form-data; name="file"; filename="/C:/Users/XXXXXX/Downloads/14016_RolloverForm.pdf"
Content-Type: application/pdf

(data)
----WebKitFormBoundary7MA4YWxkTrZu0gW

ManishJain
Solution Sage
Solution Sage

Hi @FoDelement ,

 

Unfortunately I do not have answer for attaching the file for testing in Custom Connector. But what you can do is place a file in Sharepoint and do get file content of Sharepoint action and in the next step use HTTP request POST call with above information. Add only Content Type ,Authorization and File name in Header and in Body use content of previous action. 

 

Thanks

Sadly our server requires VPN, so that is why we use a custom connector (For the data gateway).

 

Thank you for the tips. I will keep trying. 😁

ManishJain
Solution Sage
Solution Sage

@FoDelement , 

 

When I say HTTP request you can use the same Authorization Header and this HTTP Request action is available in Flow to test . 

 

Thanks

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Users online (34,818)