last day (17 days later) » 

7:32 PM
0
A: mule flow to create and download files

David DossotThere's a design flaw in your approach. com.trinet.rest.RestIntegration should be the place where the expected response is created: Fix @Produces so it returns text/csv, Move the logic of appendData into postOperation, Set the Content-Disposition header inside postOperation. Thus, there shou...

 
akb
Set the Content-Disposition header inside postOperation. How do I set in my Rest class file? Do I set both mimetype and content type in Java is better?
 
And no: keep using @Produces for the response content type.
 
akb
I have added return Response.ok(res).header("Content-Disposition", "attachment;filename=QuickbooksAccountsJava.iif").build(); made @Produces("text/csv") and having only rest call in mule. But file still doesn't download.
 
Can you pastebin a curl -v interaction please? I'd like to see the exact response, including headers.
 
akb
updated above, I am using rest client from Chrome and in windows env.
 
7:32 PM
Things look good: why do you say it doesn't work?
 
akb
File doesn't download to my local system. As I had informed earlier, If I dont have java component, A file called QuickbooksAccountsJava.iif use download locally to my system, I need this file to proceed further.
 
akb
7:47 PM
If I remove the Rest call in my mule flow, a file gets downloaded to m local system.
 
honestly I don't get it
from Chrome Rest it seems all is good
the right content-disposition header is there
not sure what else you want?
 
akb
My requirement is download a file with the payload contents.
 
I see the payload in Chrome Rest
I see !TRNS and whatnot
it seems the content is correct
 
akb
yes content is correct, but I need that content in the file attachment
that is the reason I have put <set-property propertyName="mimeType" value="text/csv" doc:name="Property"/>
<set-property propertyName="Content-Disposition" value="attachment;filename=QuickbooksAccountsJava.iif" doc:name="Property"/>
 
but you get the exact same headers with pure JAX-RS, as you can see from Chrome
oh I see there's this mimeType header that's different
that's not a standard HTTP header
I think you meant Content-Type
 
akb
7:59 PM
yes
 
anyway, I still don't get the problem
is the file downloading?
if you HTTP POST on localhost:9192/QBRest/post{an_id} do you get the response file back?
 
akb
now I have clicked Save as file then it is downloading.
 
wait, what?
how do you POST on this URL?
 
akb
but that downloads the response content
 
right, that's what you want right?
 
akb
8:02 PM
it wont do auto download the file?
 
I don't understand "auto-download"
how do you do the HTTP POST?
from a form on a web page?
via an Ajax call?
 
akb
when I run a sample application without rest call, i get a file downloaded automatically to my local system and the file name is QuickbooksAccountsJava.iif
 
how do you do the HTTP POST?
 
akb
If I include rest component in my mule flow, I am expecting same file to be loaded with the content.
ok, is there a different way to do that?
 
and it is, as you can see from Chrome
I really don't understand the issue
 
akb
8:06 PM
where is that file in Chrome?
 
it depends where you saved it
 
akb
I didnot give any special path for it, how do I get the path for it?
 
it's when you save the response from the HTTP POST
how do you do the HTTP POST?
 
akb
I do http post by selecting operation as POST, then give url and then input data in Payload and click Send by using Chrome
 
gotcha
so this is what's visible in the screen shot
 
akb
8:10 PM
yes, correct
 
I was wondering if you had another application, like a web application, calling this endpoint on Mule via an HTML form
so if you save the file, is the content correct or bad?
 
akb
no idnot have web application, I just use mule flows with rest client
 
OK, then, I think you're good, it seems the data Mule sends is correct
 
akb
ok
thanks
is there anyway that I can specify the file location to download to particular location?
 

  last day (17 days later) »