REST: native support of multipart/form-data
6025
Views
27
Comments
Implemented
Data & Integrations
Development Environment 11.53.40 (Build 61951)

Many REST services implement sending files, documents etc. by having a body with multipart/form-data. There are many questions on the forum about this, e.g. here, here and here. Unfortunately, the OutSystems Platform lacks native support for this, leading to workarounds like this Forge Component or "manually" modifying the request data in the OnBeforeRequest, which leads to things ugly code like this:

(Yeah, that's mine :).)

So it would be a great addition to the Platform if it had native support for multipart/form-data for REST services, at the very least for consuming them. That would make our lives just a tad bit easier!


Hi,


I've dealt with this problem in the past, a definitive solution would be much welcome.

PS: your flow art design qualities need improving. :p

I already wrote it's ugly code :).

I've already implementes some REST services with uploads in outsystems, so I would gladly pay a beer to have this implemented!

I'm in the middle of implementing something like this. Killan care to share that snippet to get me started?

I've published this explanation on Medium and created this component to deal with the more difficult parts.

Good Idea!!!

good idea, I'm struggling with the multiparts right now.

Hi Peter,

Did you see my links to my article and Forge component? If you're still struggling, feel free to post a question on the forum.

Yes, I found later and then I've implemented the component Multipart/form-data , works fine, thanks..

Great, be sure to give it a few stars :).

Good Idea :)

My Vote for you !!!

Hi Kilian,

Is you component can be used in reactive web development? Or it is only suitable for traditional web?

Hi Ambikesh,

Such questions are better asked in the component's subforum, this is the Idea section!

This would be an awesome addition, especially in the exposing REST section where we can't use the same type of workaround as when consuming.

Is there a Mobile compatible component available for Multipart form data?

Hi Shishir,

All REST calls, also on Mobile, are sent through the server. So there is no need for a specific Mobile component.

Changed the status to
Working on it
expected delivery in 23-Quarter1

Hi Killian, just to let you know we plan to soon release the ability to consume REST services using multipart/form-data as request format. 

Changed the status to
Implemented
on 20 Feb 2023

Hi Kilian,

I'm glad to announce that this capability is already available on the latest Service Studio 11.53.40 along side Platform Server 11.19.0.

Thanks

Great Fernando, thanks for all the hard work 😄.

@Kilian Hekhuis sadly, while they've implemented it... it doesn't actually work... or at least not if you want to send Binary and JSON, which is the only time you really need it. 

It converts binary data to text and dumps it in the body... which is useless.  Your solution, we assume, does the opposite. 

Maybe OutSystems could take your solution, which I'm now using (thank you) after wasting days trying to get the OutSystems one to work, and base their solution on that. 

Nathan 

I haven't tried to use the native solution, but I would assume that it would actually work, and what you've encountered is the result of you not filling the right RequestPart attribute. Make sure you fill PartBinary, not PartText, for the binary parts, and use PartText for the JSON.

@Kilian Hekhuis sorry, you misunderstood.

Yours works perfectly, it's the native solution that is sending Binary data as text.

OutSystems need to copy how your solution does it. 

No no, I actually meant the OS solution. It is almost a verbatim copy of my solution, so if filling PartBinary produces text instead of binary, that's a bug and you should contact OS Support. But I'm glad my Forge asset works as expected :).

@Kilian Hekhuis ah I see now.

It looks like they haven't implemented it the same way in the interface.

They've done it like this, where you pass in JSON/binary parameters:

I'm guessing behind the scenes they are mistakenly adding all the parameters in to PartText.

I'll raise a ticket and reference this thread. 

You should check the documentation, because that image doesn't look like what the documentation says it should.

@Kilian Hekhuis many thanks, I had not seen that documentation, only documentation with competing instructions.