Modify REST API response to Csv format

Modify REST API response to Csv format

  

Hi there,

Can anyone tell me how to customize the response of a REST API ? My API only has one Get method.

I know I can use the On Response property of the REST API to achieved this (perhaps using REST-EXTENDER?) but I have no idea how to do it (any example I can look at?). I want to change the response from Json format to Csv, my output is a list of a simple structure.

Thanks in advance =)

Lorena 

Hi Lorena,

can you explain a bit more what's your API supposed to achieve? I'm not sure what you want to do requires manipulating the response like that.

On the OnResponse, you can manipulate the entire text of the HTTP Response of your REST method before it is sent to the caller... but you will have to parse it (the body of the HTTP Response is preceded by an empty line followed by CRLF (check here, here and here for several different descriptions of the format).

Solution

On top of what Jorge says, you can make use of the String_Join from Text Extension to easily convert the list of structure to csv. 

Solution