Making Django REST API POST/PUSH call - How to automatically create JASON object?

Seven Stars

Making Django REST API POST/PUSH call - How to automatically create JASON object?

 

I had few complex ETL jobs which are working fine. However, instead of directly hitting the DB, I wish to utilize REST APIs to do that. I figured that I need to deploy the tWriteJASONField node somewhere but I am not being able to figure out how.

 

I envision something like:

Existing -> Job --- tMAP --- DB write

being changed to :

New      -> Job --- tMAP --- tJASONWrite --- tRESTClient

Also the tJASONWrite component needs JASON tree structure to be specified. Do I have to create that manually, every time, for every job? I'm assuming there is a way to do that automatically, based on the input row schema.

 

So far, I've got the GET working fine and I could fetch the JASON object but I primarily need the PUSH and POST working.

 

Any thoughts on this would be appreciated.

Ten Stars

Re: Making Django REST API POST/PUSH call - How to automatically create JASON object?

You want some auto-conversion from row -> JSON structure?! 

 

However think on how your POST/PUSH works expect to receive:

{ "id" : 0 , "name" : "foo" , "age" : 24 }

Or

{ "target" : "person" , 
"update" : [
      { "id" : 0 , "name" : "foo" , "age" : 24 },
      { "id" : 35, "name" : "foometwice" , "age" : 65 }
    ]
}

Or ..... so many different ways 

 

"Auto conversion" is possible with tJSONWriteField ... you can do some automapping isnt there a checkbox ,  but you probably need to adjust this output to fit your push/post, but it ends up in an array like the first example. There;s no magic component to do it for you beside writing some Java code and tJavaRow / tJavaFlex ... 

However to read/write dynamic schema in Open Studio... take a closer look on this thread : https://community.talend.com/t5/Design-and-Development/Dynamic-schema-alternative-in-Open-Studio/m-p...

 

Keep it clean, sometimes it helps being clear on what you're trying to do!

Seven Stars

Re: Making Django REST API POST/PUSH call - How to automatically create JASON object?

I got derailed due to some other priorities and couldn't focus on this effort. Going to focus on this now.

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog