Hello Team ,


I am able to call api from postman as post method for uploading file into server.

But when i am consuming rest api in outsystems .I am not getting, how to set data in form-data .

I can only set send as body to input parameter.

I have attached an image of postman for reference.

Can anyone tell me how to test this api on outsystems platform.


 

Hi Daniel , 

Above link is really help full for me .

Now i am passing content-type to multipart/form-data  .

But still i am not able to get response, getting error in response .

HTTP/1.1 500 InternalServerErrorContent-Type: application/json; charset=utf-8(Show all headers)

{  "messages": [    "Value cannot be null.\r\nParameter name: header"  ],  "developerMessage": null}


It seems that i am missing some more parameter related to header.


Hi Vivek,

In the meantime i removed my post, as I thought it would not apply for mobile apps,

Related to the article i posted there is another Forge component that you could have a look at:

https://www.outsystems.com/forge/component-overview/4026/multipart-form-data

Regards,

Daniel



Hi Daniel,

Thanks for your suggestion ,But i dont wont to use forge component.

Can you please let me know how i can active in outsystems .



Just open the link and press the Install button.

From there follow the instructions.

For a complete guide on how to install a Forge component you can read the next document:

https://success.outsystems.com/Documentation/11/Getting_Started/Use_a_Forge_Component_Made_by_the_Community

Regards,

Daniel

Hii Daniel,

I dont wont to use forge component.

I want to consume Api in my own module .

Hi,

It wasn't perfectly clear from how you wrote it in your previous post.

Anyhow you could just install it and see if it does what you need and learn from it. They ayou use that in your own code.

Regards,

Daniel

Vivek Patel wrote:

Hello Team ,


I am able to call api from postman as post method for uploading file into server.

But when i am consuming rest api in outsystems .I am not getting, how to set data in form-data .

I can only set send as body to input parameter.

I have attached an image of postman for reference.

Can anyone tell me how to test this api on outsystems platform.


 


Hi Vivek,


this should be very easy, but I cannot see te problem in your attached image.....
Is it possible to also send a image from the header tab from postman?
Also the end-point would be nice :-)

Best regards,
Jeroen 

Jeroen Vormer wrote:

Vivek Patel wrote:

Hello Team ,


I am able to call api from postman as post method for uploading file into server.

But when i am consuming rest api in outsystems .I am not getting, how to set data in form-data .

I can only set send as body to input parameter.

I have attached an image of postman for reference.

Can anyone tell me how to test this api on outsystems platform.


 


Hi Vivek,


this should be very easy, but I cannot see te problem in your attached image.....
Is it possible to also send a image from the header tab from postman?
Also the end-point would be nice :-)

Best regards,
Jeroen 

Hi Jeroen,


Nothing to add in header part .

I have just used method POST ,URL of API and added values in body as key value pair shown in image.

Its working fine from postman, just need to know how to use from outsystems . 


Daniël Kuhlmann wrote:

Hi,

It wasn't perfectly clear from how you wrote it in your previous post.

Anyhow you could just install it and see if it does what you need and learn from it. They ayou use that in your own code.

Regards,

Daniel

Hi Daniel ,

I used the forge component suggested by you but when i go inside the component they have used extension .

Which i dont want to use.


Vivek Patel wrote:

Jeroen Vormer wrote:

Vivek Patel wrote:

Hello Team ,


I am able to call api from postman as post method for uploading file into server.

But when i am consuming rest api in outsystems .I am not getting, how to set data in form-data .

I can only set send as body to input parameter.

I have attached an image of postman for reference.

Can anyone tell me how to test this api on outsystems platform.


 


Hi Vivek,


this should be very easy, but I cannot see te problem in your attached image.....
Is it possible to also send a image from the header tab from postman?
Also the end-point would be nice :-)

Best regards,
Jeroen 

Hi Jeroen,


Nothing to add in header part .

I have just used method POST ,URL of API and added values in body as key value pair shown in image.

Its working fine from postman, just need to know how to use from outsystems . 


Hi Vivek,


in that case:
which API are you trying to consume? A 3rd party or some from within you company?
If it is the first, could you specify the endpoint? 


Hi Vivek,

if you don't want your thingy to be public, you can also email me at jeroen@vormerict.nl

Solution

Hi Vivek,

you have to pass all your form data as binary because you have to also upload a file content.
Every form-data should start with a boundary which should also be specified in your header:
Your header "Content-Type" should be for example: 

SyntaxEditor Code Snippet

"multipart/form-data; boundary=Vivek"

Then each form data should be something like this:

SyntaxEditor Code Snippet

NewLine() + 
"--Vivek" + 
NewLine() +
"Content-Disposition: form-data; name=""" + <formData field name (key)> + """" + 
NewLine() +
<field value>


In case of a file the form data should be something like this:

SyntaxEditor Code Snippet

NewLine() + 
"--Vivek" + 
NewLine() +
"Content-Disposition: form-data; name=""file""; filename=""" + <filename> + """", "") + 
NewLine() +
<file content (binary)>

All formdata text can be changed to binary using TextToBinaryData (from the BinaryData extension).

The all data should be concatenated using BinaryConcat (from BinaryConcat extension).
You can use the result of this concat in your request input parameter BinaryData in body).
In this request you have to use also the header mentioned above (multipart/form-data; boundary=Vivek).

This boundery also should be on the bottom of the total request (as binary) like:
--Vivek-- (including the dashes)


Obviously the response is depending on the API you're using....

I've sent an OML by email you can use for the particular API you are using.

Best Regards,
Jeroen



Solution