[resolved] tRESTClient to Mongo

One Star

[resolved] tRESTClient to Mongo

Hi everyone,
Please forgive me if I skipped something easy I'm new with Talend. 
I want to do something that sounds simple to me. I get JSON array by a RESTful API, and I want to insert all the datas in a mongo collection.
I've got already the plugins for mongo.
Thx !

Accepted Solutions
One Star

Re: [resolved] tRESTClient to Mongo

Okay so I finally found the error. The connection to mongo wasn't established yet.
In the other cases, it works because (I think) I placed a mongoInput before the table and in this case not
Really sorry, sh***y mistake .....
Thx for your time and implication by the way

All Replies
Moderator

Re: [resolved] tRESTClient to Mongo

Hi,
Have you already checked component TalendHelpCenter:tMongoDBOutput which inserts, updates, upserts or deletes documents in a MongoDB database collection based on the incoming flow from the preceding component in the Job.

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.
One Star

Re: [resolved] tRESTClient to Mongo

hi,
Thx your reply. After some researches, I finally found the issue. 

This was the main mistake I made. My job wasn't good at all too. This is what I do and now it works:


Everything works fine now. 


But I'm facing another problem with Excel. 
 
What's wrong ? It works if I replace mongoOutput with something like LogRow.
Edit: Oh and another question, are plugins (mongo) updated on the exchange ? I got a problem with authentication and it should be resolved:
https://jira.talendforge.org/browse/TDI-22062
Thx
Moderator

Re: [resolved] tRESTClient to Mongo

Hi,
For your issue(java.lang.NullPointerException), could you please show us the component setting screenshot of tMongoDBoutput? Is DB connection OK with you?
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.
One Star

Re: [resolved] tRESTClient to Mongo

Connection to DB should be good, as I did the same config for the other jobs.
But I just can't do the same way with the Excel component. Maybe by putting JSON fields on the way ?
Moderator

Re: [resolved] tRESTClient to Mongo

Hi,
Have you tried to use tfileinputjson component to see if it is OK with you?
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.
One Star

Re: [resolved] tRESTClient to Mongo

Hi,
Yes, but not fileinput.
I tried this way:
Excel -> Map -> FileOutputJSON
If I put logrow at the end, it works. If I put Mongooutput, fail. And always this error:
Exception in component tMongoDBOutput_1
java.lang.NullPointerException
at test.integration_excel_0_1.integration_excel.tFileInputExcel_1Process(integration_excel.java:814)
at test.integration_excel_0_1.integration_excel.runJobInTOS(integration_excel.java:1757)
at test.integration_excel_0_1.integration_excel.main(integration_excel.java:1614)
Am I missing something ? Excel headers, or chars, or whatever that could be problematic ?

EDIT: the error is at this line:
com.mongodb.DBCollection coll_tMongoDBOutput_1 = db_tMongoDBOutput_1
.getCollection("buddytest");
BUT this is present in the other jobs, and works fine. 
One Star

Re: [resolved] tRESTClient to Mongo

Okay so I finally found the error. The connection to mongo wasn't established yet.
In the other cases, it works because (I think) I placed a mongoInput before the table and in this case not
Really sorry, sh***y mistake .....
Thx for your time and implication by the way
Moderator

Re: [resolved] tRESTClient to Mongo

Hi brian.dechoux,
Okay so I finally found the error. The connection to mongo wasn't established yet.
In the other cases, it works because (I think) I placed a mongoInput before the table and in this case not
.

Thanks for your feedback. Can you use tMongoDBConnection to open a connection to a database in order that a transaction may be made?

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.