having issues using tRestClient or tRest component to upload a file

One Star

having issues using tRestClient or tRest component to upload a file

I have the need to upload a binary file to a RESTful webservice where the REST service has the following signature in Java:
@POST
@Path("/uploadFile")
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response uploadFile(
@FormDataParam("file") InputStream uploadedInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail) {

However, I am not able to get this to work with the tRestClient component or the tRest component.
Any help would be much appreciated.
currently, I am using "Talend Open Studio for Data Integration 6.1.0.20151029_1337"
I have control over the REST service, so changing the method parameters is possible.  All I need to capture is the binary file and its name.
Moderator

Re: having issues using tRestClient or tRest component to upload a file

Hi,
How did you set your tRestClient component? What's the error you are getting?
Have you checked the scenario in component reference:TalendHelpCenter:tRESTClient?
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Seven Stars

Re: having issues using tRestClient or tRest component to upload a file

Hi,
I also have same scenario. I want to upload files/images by using tRestClient/tRest component.
I have successfully uploaded files/images by using POST man client. But by using tRestClient/tRest components I am not able to upload file. I have gone through documentation of components.
I also tried with tFileFetch component.
I want to know where I can provide file name . Because my API signature contain one parameter i.e file.
Please have screen shot of POST man Request.
Thanks & Regards
A Ravi Kumar
Mobile Number : +91 852-762-1083
Email-id : a.ravikumar104@gmail.com
Skype Id : ammanannaravikumar
Four Stars

Re: having issues using tRestClient or tRest component to upload a file

I had to call an HTTPS POST API using Content-Type: multipart/form-data to send some parameters, post a json file and receive the response.  Nothing I tried with tREST or tRESTClient worked.  
Talend Support suggested tFileFetch to upload the file.  I saw nothing in the tFileFetch documentation which indicated I could get the response from the API call, so I never tried it.
I did get it to work using tFileFetch.  It turns out the API response is provided in the destination filename (wasn't expecting that). 
Moderator

Re: having issues using tRestClient or tRest component to upload a file

Hi,
I did get it to work using tFileFetch.  It turns out the API response is provided in the destination filename (wasn't expecting that).

Do you mean the API response is loaded into your destination file(tFileFetchDownloadFile.txt) or the API response is saved as destination file name(APIResponse.txt)?
Could you please give us the screenshot of your API response which will be helpful for us to understand your problem.
Many thanks!
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Four Stars

Re: having issues using tRestClient or tRest component to upload a file

Hi Sabrina,
I meant the API response is loaded into the destination file(tFileFetchDownloadFile.txt).
There is no problem at this time.