cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FoDelement
Continued Contributor
Continued Contributor

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

FoDelement
Continued Contributor
Continued Contributor

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
Continued Contributor
Continued Contributor

@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

FoDelement
Continued Contributor
Continued Contributor

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 Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,545)