Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Ahhouais
Contributor
Contributor

Web service : send a csv file in response

Hi everybody,
I would like to design a Web service that can send a user un file (.csv or .txt) containing some rows extracted from a table.
I want to call this Web service from a browser and I want to be able to give some parameters in the URL. 
For instance, I want to send a file containing all the countries with a name starting by a letter. 
The URL could be http://localhost:8040/listCountries?letter=F
For designing this Web service, which components can I use ? 
I though to this orchestration : 
tRESTRequest --tFlowToIterate--tMySQLInput--tXMLMap--tRESTResponse but I have some questions :
1) How can I get the parameter 'letter' given in the URL ? 
2) Once I have executed the request, how can I set the tRESTResponse to send a file ?
Any help would be appreciated.
Thanks
Labels (4)
4 Replies
Ahhouais
Contributor
Contributor
Author

Hi,
I have done this : 
tRESTRequest--(main)-->tFlowToIterate--(iterate)--tJava--(onComponentOK)--tFixedFlowInput--(main)--tXMLMap--(main)--tRESTResponse
In the tJava, I have hardcoded some lines in order to put the file in a globalMap as a byte array :
String filePath = "C:/eula.1036.txt";
byte[] t_byte = (byte[]) routines.SynotisFileUtils.getByteArrayFromFile(filePath);
globalMap.put("mon_fichier", (byte[]) t_byte); 
In the tRESTResponse, I have set the "Content-type" ("text/plain") and the "Content-disposition" ("attachment").
It seems to work but the file is empty...
Any idea ?
Ahhouais
Contributor
Contributor
Author

Any idea ?
_AnonymousUser
Specialist III
Specialist III

4FMPci <a href="">gyzqdbdcujdu</a>, osbeugmytpcu, fgnyltdbsoen,
Ahhouais
Contributor
Contributor
Author

Sorry ?
Still can't send my result in the response...