Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

send file with tRestClient

Hi everyone,

I'm retreiving a file in base64 from a route and trying to send it to an API through the component tRestClient. I convert the base64 into a file without any issue but i struggle to send it on the API

 

I don't understand how to use it. I tried to put the complete path of the file into a query parameter with no success. 

Here is what i've done :

0683p000009MaFx.jpgthe job0683p000009MaG2.jpgtRest config

I'm really not sure how to do it. I can't use a tFileFetch because my API is waiting for 3 parameters: file, type and fileName

0683p000009MaG7.jpg

I'm used to send body messages with JSON but i don't understand how use it to send a file.

 

Thanks for the help!

Labels (4)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi everyone, 

I finally succeeded by modifying the component tFileFetch.

The API was sending me a 201 response so i had to modify the code of the component to accept this code as a valid response:

 

 

status_<%=cid%> == org.apache.commons.httpclient.HttpStatus.SC_OK<%= scaccepted_uploadfile%>

became

 

status_<%=cid%> == org.apache.commons.httpclient.HttpStatus.SC_OK<%= scaccepted_uploadfile%> || status_<%=cid%> == org.apache.commons.httpclient.HttpStatus.SC_CREATED<%= scaccepted_uploadfile%>

I have now a new issue related to "Method failed: HTTP/1.1 413 Request Entity Too Large"

But not related directly to that topic

View solution in original post

6 Replies
BhavikaW
Contributor III
Contributor III

Hello,

If a file data needs to be passed to trestclient as query parameter then the string has to be created with all the columns of file in json format as we have string  column in output schema. Also body column needs to be created with documnet type as the below screenshot.

 

0683p000009MaG3.png

Then pass the result to restclient and refer below screenshot for your reference

0683p000009MZmi.png

The schema of response has to be configured as given above

Regards,

BhavikaW

Anonymous
Not applicable
Author

Hi Bhavika,

Thanks for the reply but I'm trying to send a PDF so i can't read it Smiley Sad

akumar2301
Specialist II
Specialist II

Try tfilefetch with “Upload file” option
Anonymous
Not applicable
Author

akumar,

Thanks for the answer, but the link http://talend.nl/talend-tech-tip-calling-a-rest-service-for-file-upload/ isn't working

 

My issue is that i have to send data in the same time i need to send the file. I tried to not putting them, it works with a POSTMAN but not in Talend and i don't know why. I tried to put them in the "Parameters" section of the tFileFecth, always getting this message :

There isContinue_tFileFetch_1 an exception on: MY_API
java.lang.Exception: Method failed: HTTP/1.1 201 Created

 

0683p000009MZrg.jpgtfilefetch config0683p000009MZrl.jpgthe "same" on POSTMAN

 

Any idea?

Anonymous
Not applicable
Author

Hi everyone, 

I finally succeeded by modifying the component tFileFetch.

The API was sending me a 201 response so i had to modify the code of the component to accept this code as a valid response:

 

 

status_<%=cid%> == org.apache.commons.httpclient.HttpStatus.SC_OK<%= scaccepted_uploadfile%>

became

 

status_<%=cid%> == org.apache.commons.httpclient.HttpStatus.SC_OK<%= scaccepted_uploadfile%> || status_<%=cid%> == org.apache.commons.httpclient.HttpStatus.SC_CREATED<%= scaccepted_uploadfile%>

I have now a new issue related to "Method failed: HTTP/1.1 413 Request Entity Too Large"

But not related directly to that topic