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

Custom Connector: How to POST binary body?

I have some tests working in Postman that POST binary data (.jpg) to an endpoint. This works just fine, but there is no visible schema for the `body` of this request. Its just "binary data" I guess. 

seadude_0-1629003025661.png

 

What do I select in PowerApps Custom Connector to allow binary data in the `body`? Do I need a schema of some sort? 

seadude_1-1629003162751.png

 

5 REPLIES 5
murshed
Microsoft
Microsoft

Hi,

Can you please tell us little more what you are trying to do? Where is this binary data coming from? You can probably work with content-type for this. Also look at this article to work with base64 encoding and binary data: https://linnzawwin.blogspot.com/2021/02/handle-base64-and-binary-file-content.html

If this reply answers your question or solves your issue, please ACCEPT AS SOLUTION ☑️. If you find this reply helpful, please consider giving it a LIKE 👍.

Syndicate_Admin
Administrator
Administrator

I had the same problem and finally figured it 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.

 

Hope that helps anyone else stumbling across this post because they're stuck on the same thing!

 

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.

Syndicate_Admin
Administrator
Administrator

I was able to figure this out. Believe it or not, the Body was not required!

image.png

Syndicate_Admin
Administrator
Administrator

Glad you figured yours out! I just edited my solution to note that I'm still getting an ominous warning. So far it's been working fine, but what I'm doing doesn't seem to be officially supported.

Syndicate_Admin
Administrator
Administrator

here is an example from Github:
https://github.com/microsoft/PowerPlatformConnectors/blob/master/custom-connectors/ServiceNow/apiDef...

 

there is an example POST on line 471 - 644,

Cam_1-1653466483420.png

 

631-640 contains the file element

Cam_2-1653466607046.png



i'm not sure what to make of this information.... but hopefully it helps someone 🙂

(there is a content type element on row 611 - 630 too)

 

 

 

note: the above is in JSON, so you will need to convert to YAML to use in your custom connector

https://www.json2yaml.com/

 

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

New Process Advisor Capabilities carousel.png

Read the blog for the latest news

Read the latest about new experiences and capabilities in the Power Automate product blog.

PA Survey Carousel Image.png

We want to hear from you!

If you are a small business ISV/Reseller, share your thoughts with our research team.

AI Builder AMA June 7th carousel (up on May 25th, take down June 8th) (1).png

'Ask Microsoft Anything' about AI Builder!

The AI Builder team invite you to ask questions and provide helpful answers at our next AMA.

Top Solution Authors
Users online (1,491)