Sending an image in a REST Post Request
Question

I have done the following:

1. Created a REST API POST request to the desired url

2. Added contentType field with a value of 

"multipart/form-data; boundary=Vivek"

3. Used BinaryConcat and concatenated the following:

     a. 

TextToBinaryData(NewLine() + 
"--Vivek" + 
NewLine() +
"Content-Disposition: form-data; name=""file""; filename=""" + UploadCacheTable.List.Current.UploadCache.Filename + """" + 
NewLine())

    b. 

UploadCacheTable.List.Current.UploadCache.Content

4. Then, used BinaryConcat and concatenated the result of the previous with the following: 

TextToBinaryData("--Vivek--")

Now, when I am invoking the request, I get:

500 Internal Server Error

Solution

You can download component and demo and after you can install the .oap files.

I only know  "Multipart/form-data" component. Perhaps you must adapt the code a little to your needs but it is a good starting point.

Kind regards, David.

Hi,

You can take a look these components in the forge: https://www.outsystems.com/forge/list?q=form-data&t=&o=&tr=False&oss=False&c=%20&a=&v=&hd=False&tn=&scat=forge

Specifically I have used "Multipart/form-data" component (https://www.outsystems.com/forge/component-overview/4026/multipart-form-data) in order to send multiple files. You also can review the demo application of this component. I hope it will be useful to you.

Kind regards, David.

I cannot fond the demo application. Can you attach the OML?

Also, can I use anyone of which to send key, pair form data or do all of them send data in the binary format?


Solution

You can download component and demo and after you can install the .oap files.

I only know  "Multipart/form-data" component. Perhaps you must adapt the code a little to your needs but it is a good starting point.

Kind regards, David.

Thanks a lot. This really helped. I did not know that there are demo applications attached to the forge components

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.