cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Syndicate_Admin
Administrator
Administrator

Custom Connector: binary body

I have the exact same problem described here. The endpoint I'm working with expects a content type such as 'application/pdf'. It does not expect a form, json, etc. - just the raw binary as the body.

 

For example, in Curl, the data can be sent using  --data-binary and --header 'Content-Type: application/pdf'.

 

Unfortunately, OpenAPI 2.0 (Swagger) only supports file upload as part of multipart/form-data. I can't figure out whether there's any extension or workaround in Power Automate to allow for other content types.

 

I tried to use OpenAPI 3.0, but it's not supported AFAICT. I tried to use a script to transform the incoming request from multipart to a simple binary body, but I haven't figured out how to do that in C#. I thought maybe there would be an existing Policy to transform the request, but I can't find any.

 

Is there any way to do this?

1 ACCEPTED SOLUTION

Accepted Solutions
Syndicate_Admin
Administrator
Administrator

Okay, I figured this out. You can use the Swagger editor and add a body parameter like this:

      parameters:
      - name: body
        in: body
        schema: {type: string, format: binary}

 

It appears as a string parameter in the swagger editor and on the custom connector testing tab, but then when you're in the actual flow editor you can put the "File content" from a previous step in there and it gets sent as plain binary. I absolutely did not expect that to work, but it does.

 

Edit: I later noticed that the paconn validate tool gives a warning that  "the MIME type 'application/octet-stream' is not supported" when I try to set the content-type. So maybe what I discovered was a dirty hack, and not the intended behaviour after all.

View solution in original post

1 REPLY 1
Syndicate_Admin
Administrator
Administrator

Okay, I figured this out. You can use the Swagger editor and add a body parameter like this:

      parameters:
      - name: body
        in: body
        schema: {type: string, format: binary}

 

It appears as a string parameter in the swagger editor and on the custom connector testing tab, but then when you're in the actual flow editor you can put the "File content" from a previous step in there and it gets sent as plain binary. I absolutely did not expect that to work, but it does.

 

Edit: I later noticed that the paconn validate tool gives a warning that  "the MIME type 'application/octet-stream' is not supported" when I try to set the content-type. So maybe what I discovered was a dirty hack, and not the intended behaviour after all.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,227)