How to consume HTTP POST REST API using multipart/form-data method

How to consume HTTP POST REST API using multipart/form-data method

  

Hi,

I need to consume REST API in outsystem, the type of the request is HTTP POST and data being sent in the body in the form of multipart/form-data. Please let us know how to do configuration for this in outsystems.


What should be the Request Format (JSON/Binary/Plain Text/Form URL Encoded) in the configuration and what should be the data-type  of the input parameter (Text/Binary ..)  in that case ?

Hi Akshay,

Consuming REST APIs with multipart/form-data is not possible out of the box with OutSystems. See here and here for more information.

First of all I apologize that I still have not got the time to publish the component for consuming multipart REST web service. 

@Akshay: As suggested in above comment here, you can study code and action mentioned in my comment but that action is for specific request.

Let us know what is your request payload or HTTP Post request from postman so that we can assist you better to consume the web service.

Thanks and Regards,

Suraj Borade

For anyone who comes across this topic, here's an Idea to have OutSystems support it natively. Please like :).

I'm also just looking at doing this. Just researching at the moment. So is the general idea is just to create a dummy rest integration, and then manipulate that using OnBeforeRequest ?

Hi Tesaro, 

You cannot do this in OnBeforeRequest since you need to manipulate the binary data and JSON data. Let us know what is your requirement and we will be able to assist you.

Thanks and Regards,

Suraj Borade

Kilian Hekhuis wrote:

For anyone who comes across this topic, here's an Idea to have OutSystems support it natively. Please like :).

I just liked your idea.


Suraj Borade 

I am trying to call a rest service which has content type : multipart/form-data

then attach a Payload File, which is a csv, or dat type file.


Further down the track, I will also need to do this for a SOAP service. have the file as an attachment (soap with attachment standard). In this instance, which is why leaving it to later, although its a soap service, there is no WSDL, so will have to get around that as well.




@Suraj: You can very well do this in the OnBeforeRequest, I just did so last week*. Please don't say things that aren't true.

@Tesaro: You can forget about SOAP, you'll need an Extension for that. There's no way to manipulate the SOAP contents inside OutSystems itself (there's no equivalent of the REST OnBeforeRequest for SOAP).

*EDIT: I'll see if I can post a short guide on this, and link from that to here.

@Kilian, if you can post some pointers that ould be much appreciated. I am somewhat a beginner to OutSystems, but come from a .net background, so any tips, hints, etc for OutSystems would be much appreciated.  Thanks in advance 

Kilian Hekhuis wrote:

@Suraj: You can very well do this in the OnBeforeRequest, I just did so last week*. Please don't say things that aren't true.

@Tesaro: You can forget about SOAP, you'll need an Extension for that. There's no way to manipulate the SOAP contents inside OutSystems itself (there's no equivalent of the REST OnBeforeRequest for SOAP).

*EDIT: I'll see if I can post a short guide on this, and link from that to here.


@Kilian Sir,

If it is single file or only attachments, it will work inside OnBeforeRequest but when you want to send JSON inputs and multiple attachments, it's bit difficult to customize the request inside that because only one Input parameter is available in we service for binary data.

Also exception handling becomes difficult inside OnBeforeRequest.

@ Tesaro Do you only want to attach single file through web service  or does it have any other inputs?

So what i need to pass:

header : content-Type and Auth

Body: Form-data (ID1, ID2, type, and File)

am okay if its just one file, for now, can send the message twice if a 2nd file is needed


@Suraj, it's really not a problem, trust me :). I'm writing an article as we speak, when it's finished I'll post a link to it here.

@Tesaro, just a little more patience, I'll have something ready today or tomorrow :).

Ok, for starters I published a Forge Component that helps creating the body of a multipart/form-data request. It can be found here. My article is under review currently, expect it to be published tomorrow.

And finally, here's the article. Any questions are welcome here.