How to handle file response in Connector(http-endpoint)?

I have created a process flow which makes a call to a rest service and it returns a file. I am using the http-connector with input and output parameters configuration in modeler.
I am storing that in output parameter named “file” using inline script. The inline script has following code
“var response = connector.getVariable(“response”);
But when I try to use that in the “a cam-file-download=“file”” it is not working.
I added a execution listener to verify the value of variable and it is populate but the type is shown as “char” instead of “InputStream or byte array”.

Can please some one help me understand what I am doing wrong over here?

Hi @Aditya_Shah,

I cannot download your attachment, could you please explain in more detail how you want to use response?


Hi @aakhmerov,

Thank you for looking into this.

I want to make the file available as downloadable for user which is returned by “REST” call.
Also If I want to use that response in a Java Delegate to log the file.

I have attached the bpmn file.get-file-using-http-connector.bpmn (5.9 KB)



I think that response in that case corresponds to org.camunda.connect.httpclient.impl.HttpResponseImpl class, so in the moment you pass it to out mapping it will get serialized and the real stream backing will be closed. What you should do is probably read content of response and map out only the content.

Does that make sense?


How do I read the stream in Inline script? Will the javascript handle the InputStream?


groovy probably would be better suitable for that.


How can do it with groovy

@Abbas_Ulusoy be aware of: Can HTTP-Connector Receive Binary Data?