[Guide] Consume REST API with XML Request

[Guide] Consume REST API with XML Request

  

Hello,

Some time ago i had to use a REST API with a XML request and couldn´t find much info about it in OS foruns so i decided to do this quick guide so if anyone finds themself in the same position can follow it, this consists in a few easy steps:
First of all you need to consume a REST API with method set to POST and add a Content-Type header as it is in the following image:

On the method properties you just have to set the Request Format to Text.

After this you just have to create the XML request your API needs, for example the one we use:

The only Thing left is to set the new imput of the Rest Api method (ContentType) equal to 

"content-type: application/xml"

As seen in the following image:

And that is basicly all the steeps you need to follow,
If anyone has or had the same problem and need more help just ask :)
Best Regards,
Francisco Freire

Nice Fransisco, could help some people. Probably using one of the XML components in the Forge could help with building a request and receiving and decoding the response?

(I moved your post from Technology to Community Quick Guides, hope you don't mind.)

Very useful, thanks.

Kilian Hekhuis wrote:

Nice Fransisco, could help some people. Probably using one of the XML components in the Forge could help with building a request and receiving and decoding the response?

(I moved your post from Technology to Community Quick Guides, hope you don't mind.)

Hello Kilian,
Yes, using XML Forge Components and Outsystem's XML extension could help creating the request,
It is also importanto to remember to  escape some characters, our requests carry URL encoded text so we are always carefull to escape all the characters we use (for example %,&,",etc).


Best Regards,
Francisco Freire.