How can I access a ReportListToExcel on WebService?

Hello everyone,

I'm new in the outsystems world I've been working on a Web Aplication that manages activityes, and each activity must have a "ReportListToExcel" that I've done and works fine it shows na Activity that as Actions and that actions have SubActions within that Activity. This is the excel afther the Action that I attached.

My problem now is that I don't know how to grab that report and acess it by an webservice It as something to do with REST or SOAP but I don't know how to apply it there :S

Please help me.

Hi Daniel

The "Record List To Excel" provides a binary file. You can create a REST web service with a method called SendExcelFile. In this method you can set an output parameter of type "Binary Data". In this action get the list you want to convert to excel, send add the "RecordListToExcel" and set the output parameter to the RecordListToExcel data. This will return the binary excel file when you call the Web Service


Having said this, the binary data generated might be very very big (depending on the number of records) and you could start running into a lot of issues (timeouts) when calling the web service if it is done as the above. I would recommend sending instead the list and developing the logic to convert to an excel file on the back-end of wherever you will be calling this WS from.


Hope this helps!

   -CLSJ

Carlos López Santibáñez Jácome wrote:

Hi Daniel

The "Record List To Excel" provides a binary file. You can create a REST web service with a method called SendExcelFile. In this method you can set an output parameter of type "Binary Data". In this action get the list you want to convert to excel, send add the "RecordListToExcel" and set the output parameter to the RecordListToExcel data. This will return the binary excel file when you call the Web Service


Having said this, the binary data generated might be very very big (depending on the number of records) and you could start running into a lot of issues (timeouts) when calling the web service if it is done as the above. I would recommend sending instead the list and developing the logic to convert to an excel file on the back-end of wherever you will be calling this WS from.


Hope this helps!

   -CLSJ

Thank you this works with one problem, when I access the URL it downloads a .txt file and it should be na .xlsx file, where do I change this ?

But the purpuse is there if I change the .txt file to a .xlsx file on the desktop it works just fine.

Solution

Hi Daniel

To have the file download as an .xls that you need to set the Content-Type header of your REST API call. To do that, add the action "AddHeader" from the "HTTPRequestHandler" library.


Add this action to the start of the method action with the Name: "Content-Type" and Value "application/vnd.ms-excel". This should make your file download as an Excel file.


Hope this helps!

   CLSJ

Solution

Carlos López Santibáñez Jácome wrote:

Hi Daniel

To have the file download as an .xls that you need to set the Content-Type header of your REST API call. To do that, add the action "AddHeader" from the "HTTPRequestHandler" library.


Add this action to the start of the method action with the Name: "Content-Type" and Value "application/vnd.ms-excel". This should make your file download as an Excel file.


Hope this helps!

   CLSJ

Thank you very much this worked just fine ;)