Four Stars

Downloading document from REST API

I have REST API in which there is document attached we need to download.

Can you suggest any method to do so?

 

I tried following ways.

  1. Connected the tRestClient to tFileOutputDelimiter, it sends garbage values for obvious reason the document datatype cannot be read.
  2. I connected the tRestClient to tfileOutputXML, attached are the screenshot of the subjob, RESTAPI schema and properties of the tfileOutputXML and tRestClient. Body field is document type which has got some data to be downloaded. I am getting null pointer exception for the same.

Note : I am using tRestClient as the REST API which I am using has got internal redirection which can be enabled in this component only.

 

Below is the complete error log.

 

Exception in component tFileOutputXML_1
java.lang.NullPointerException
at dns_poc.api_doc_downloand_0_1.API_Doc_downloand.tRESTClient_1Process(API_Doc_downloand.java:1555)
at dns_poc.api_doc_downloand_0_1.API_Doc_downloand.tREST_1Process(API_Doc_downloand.java:867)
at dns_poc.api_doc_downloand_0_1.API_Doc_downloand.runJobInTOS(API_Doc_downloand.java:1867)
at dns_poc.api_doc_downloand_0_1.API_Doc_downloand.main(API_Doc_downloand.java:1701)
[FATAL]: dns_poc.api_doc_downloand_0_1.API_Doc_downloand - tFileOutputXML_1 null

 

2 REPLIES
Seven Stars

Re: Downloading document from REST API

You can use the tFileFetch component that allows you to download files.
Four Stars

Re: Downloading document from REST API

Hi Abhishesk,

 

Thanks for the suggestion it worked but I am afraid still the file content downloaded is garbage one.

Do you know if any encoding parameters might need to be tweaked on Talend side?

 

Thanks,

Hrushikesh.