[ardoHTTP] How to use this component in Service Studio Version 8 ?

Forge Component
Published on 20 Jan by Ricardo Silva
20 votes
Published on 20 Jan by Ricardo Silva
Can somebody highlight the basic steps in using this component with an example if possible ?
I didn't produce any documentation for this particular component because I thought the actions (with the descriptions) pretty much speak for themselves.

Basically what ardoHTTP does is perform HTTP requests and return you the resulting page. You have 4 Actions, one for each major HTTP request type (GET, POST, PUT, DELETE).

For both POST and PUT you have an extra parameter to define the payload of the request.

Imagine you want to do obtain the front-page of our forums, what you do is use the HTTPGet action with "https://www.outsystems.com/forums/" as the URL.

You'll get the Content which has the html returned by the server and also a list of the HTTP Headers returned by the server.

If you need some headers to be present in the request (for example, a Cookie or some special Accept header) you can use the HTTPHeaders parameter which all actions take.

There are also some special "headers" which control the behavior of the request (timeout, whether or not to accept compressed content, etc) which are documented in the descriptions.

This extension aims specially to aid people in implementing integrations with REST API's, so both the input and output are processed to a textual form and offer no means of getting a binary file (like an image, or a PDF).

If you still have questions regarding this extension, don't hesitate to ask and I'll do my best to respond :)
For what I understand of your explanation: is it impossible to send a binary file on the http post or put?

If it's possible, how do I do?

The current set of actions in the ardoHTTP extension do not allow accurately sending or receiving binary data.

It shouldn't be hard to modify the extension to support that use-case, though. I was kind of waiting to see if anyone had that requirement.

Can you let me know exactly with what API are you trying to integrate with?
Unfortunately, it's not something public.

We have a requirement to send a file from our different production servers to a central server to process them. I'm not a big expert on HTTP so I was trying to figure it out if, like on other stuff, outsystems had a way to do that in 2 minutes :)
Hi Carlos,

You can reference PostRequest_AddBinaryArgument and PostRequest_SubmitRequest from HttpRequestHandler. If you only need to send the binary content then you only need the second action.

I'm attaching my espace.

André I've tried that but I think it only adds on the HTTP Query String but, like I said before, I'm no big specialist on this.

Please, check if I'm doing something wrong!
Well, if it's something you're building why not BASE64 encode the file and use this extension ?

That would work :)
... or if you control both ends why not use a webservice?
Here comes a newbie question: doesn't an http request have better performance than a webservice?

It's because we already have those and each request takes 500ms. 

Our strategy was to make a request per data row. It took too long. Now we're thinking on packaging all the data on a json and make only one request with that file. And we thought HTTP request would be better than web service...

But JSON is not binary data, it's an UTF-8 encoded string.

This component was specifically made to work with JSON data (in conjunction with ardoJSON extension), so it's ok to use it for that purpose :)
And there's no issue regarding the json size? For example...if I've 1mb on json, does it affect the application or give any sort of overflow error?
Dunno, never tried it with that much JSON.

Try it and let us know how it goes :)

My intuition is that it shouldn't have any problem. I didn't hardcode any limit to the size of the requests.
I've tested a list with 100k elements of my sample structure and it worked just fine. It took around 10 seconds but it 's probably fine :) Thanks!
I found some issues on sendign the json thru the query string:

1 - If your JSON has a reserved html character, it doesn't work. Solution?
2 - You encode your JSON and that's it. But the size increases drastically. Solution?
3 - Not found yet. I was sending 5mb of text. After encode this, I have around 40mb. My IIS doesn't like this. I've tried to increase the limits of my query string max but still getting a HTTP 500. 

Any help? Any ideas?
Why on earth are you sending 5 MiB of JSON in the query string ?

Query strings are usually limited to 2048 characters, you're trying to send 5242880 ...

JSON should be on the content, not the query string.
How do I put it on the content?
You send an HTTP POST or an HTTP PUT and put it in the Data input parameter.
With the newer version a PATCH will also do, but I'd have difficulties calling something with 5 MiB a PATCH :)
This is an excepcional amount because something went wrong on our side and accumulated one week of processing. Usually, it would be around 10kb.

Ricardo, can you help me to figure it out how to use it on the client and server side? I mean, how to put and how to retrieve.

Much appreciated.
Hello Carlos,

If you're also receiving the request in the OutSystems Platform, you can use HTTPPost (Put is rejected by Outsystems Platform screens) and HTTPRequestHandler.GetRequestContent to obtain the content being sent.

You can then use ardoJSON to process back the request to an OutSystems structure.

Sending the request can be done with ardoHTTP as we've already talked about in this thread.
What happens when a timeout is exceeded? Will there be an exception? If yes, what would be the name?

For testing, I used 0 as "Timeout" header but did not see any difference in the outcome.
I'm using an HttpURLConnection and setReadTimeout for this particular operation.

According to the documentation of this method, an exception will be raised if the timeout is reached and 0 is considered infinite timeout.
Many thanks Ricardo!