Six Stars med
Six Stars

Issue with tRest

Hello Community,

 

I want to post ZIP File with tRest but it is not working. I tried tFileFecth and it is working however i can't catch the output response to log the error code.

 

I used the same config parameters as the talend documentation but i still have the same error code 400.

 

Please find attached the parameters for my config ( i declared the import java.io.FileInputStream in tjava juste before the tRest Component). Any help plz.

 

Thanks in advance,*

Med

2 ACCEPTED SOLUTIONS

Accepted Solutions
Moderator

Re: Issue with tRest

Hi,

You can do this with a little Java code in a tJava component at the beginning of your Job. Such as:

java.io.File outputFile = new java.io.File("e:/output.txt");
System.setOut(new java.io.PrintStream(new java.io.FileOutputStream(outputFile, true), true));

If you don't want pure java, here is a custom component tRedirectOutput which is used to redirect all the message printed on the console to a file.

https://exchange.talend.com/#marketplaceproductoverview:marketplace=marketplace%252F1&p=marketplace%...

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.
Six Stars med
Six Stars

Re: Issue with tRest

 

Thank you, that what i want.

 

BR,

Med

16 REPLIES
Moderator

Re: Issue with tRest

Hi,

Have you tried to use tRestClient component with MIME Multipart Form Data POST request for your job requirement?

Here is a tech article about:

http://talend.nl/talend-tech-tip-calling-a-rest-service-for-file-upload/

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.
Six Stars med
Six Stars

Re: Issue with tRest

I tried but it didn't work.

 

The only option i have now is to use tFileFetch but i still don't have any solution to catch the output response ?

 

Any idea ? i should handle the response to log the status of the output.

 

Thanks,

Med

Moderator

Re: Issue with tRest

Hi,

Here is an option "Print response to console" in advanced settings of tFileFetch component.

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.
Six Stars med
Six Stars

Re: Issue with tRest

 

Yes i print the response but in our company we have table of logs so i should log the response but i can't catch it.

 

In tRest for example you can handle the response using tMap but for the FileFetch i don't know how to do it

 

Thanks,

Med

Moderator

Re: Issue with tRest

Hello,

tFileFetch is generally used as a start component to feed the input flow of a Job and is often connected to the Job using an OnSubjobOk or OnComponentOk link, depending on the context.

Actually, you can collect console output data to a csv file by using a tJava component.

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.
Six Stars med
Six Stars

Re: Issue with tRest

 

I will try it.

 

Thanks,

Med

Moderator

Re: Issue with tRest

Hi,

Don't hesitate to post your issue here.

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.
Six Stars med
Six Stars

Re: Issue with tRest

 

 

So i tried to catch the ouput but i still have only null.

 

attached the screen of execution.

 

Any help.

 

Med,

Six Stars med
Six Stars

Re: Issue with tRest

 

Any feedback ?

 

Thank,

Med

Moderator

Re: Issue with tRest

Hello,

It's not working well when you check out "Print response to console" option in tfilefetch component?

Can you use tfilefetch component to upload .zip file? No response?

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.
Six Stars med
Six Stars

Re: Issue with tRest

Hello,

 

My job is working well i can transfer the ZIP file and i print the result in the console.

 

My problem is that i want to catch the body response and log it in the DB.

 

Thanks,

Med

Moderator

Re: Issue with tRest

Hi,

Are you using tJava component to catch the body response and log it in the DB? If so, what does your java code look like?

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.
Six Stars med
Six Stars

Re: Issue with tRest

I used tjavarow to catch the schema but i had just null in Body column.

 

I read in talend doc that i should use the input_stream file but i don't know how to do it.

 

You have any idea or example which handle this kind of cases.

 

Thanks,

Med

Moderator

Re: Issue with tRest

Hi,

You can do this with a little Java code in a tJava component at the beginning of your Job. Such as:

java.io.File outputFile = new java.io.File("e:/output.txt");
System.setOut(new java.io.PrintStream(new java.io.FileOutputStream(outputFile, true), true));

If you don't want pure java, here is a custom component tRedirectOutput which is used to redirect all the message printed on the console to a file.

https://exchange.talend.com/#marketplaceproductoverview:marketplace=marketplace%252F1&p=marketplace%...

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.
Six Stars med
Six Stars

Re: Issue with tRest

 

Thank you, that what i want.

 

BR,

Med

Moderator

Re: Issue with tRest

Hi,

Great it helps.

Feel free to let us know if there is any further help we can give.

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.