trestRequest POST method with JSON parameter and use the parameter to create a query

Four Stars

trestRequest POST method with JSON parameter and use the parameter to create a query

Hi All, 

i have a rest service with POST method. For the payload (JSON), I am considering schema as  'body' String type.

i need to extract the parameters passed in the payload and create a query and fetch data from database.

i am using 'trestRequset' component followed by 'tExtractJsonFields' component.

Could you plz help me with configuring the components to extract the Json fields.

payload:

{"ID":"5","FIRST_NAME":"kumar","LAST_NAME":"rohit"}

payload example:trestrequest.PNG

 


Accepted Solutions
Community Manager

Re: trestRequest POST method with JSON parameter and use the parameter to create a query

Your JSON is pretty simple, this will make it easy using the tExtractJSONFields component. 

{
"ID":"5",
"FIRST_NAME":"kumar",
"LAST_NAME":"rohit"
}

Make the following changes in your tExtractJSONFields component.....

1) If you set the "Read By" to "JsonPath"

2) "JSON field" to "body"

3) Create a new schema with a column for "ID", "First_Name" and "Last_Name".

4) In the "Loop jsonpath query" put "$"

5) In the Mapping table add the following JSONPaths next to the relevant column....
"ID"

"First_Name"
"Last_Name"

 

This should do it.

 


All Replies
Community Manager

Re: trestRequest POST method with JSON parameter and use the parameter to create a query

Your JSON is pretty simple, this will make it easy using the tExtractJSONFields component. 

{
"ID":"5",
"FIRST_NAME":"kumar",
"LAST_NAME":"rohit"
}

Make the following changes in your tExtractJSONFields component.....

1) If you set the "Read By" to "JsonPath"

2) "JSON field" to "body"

3) Create a new schema with a column for "ID", "First_Name" and "Last_Name".

4) In the "Loop jsonpath query" put "$"

5) In the Mapping table add the following JSONPaths next to the relevant column....
"ID"

"First_Name"
"Last_Name"

 

This should do it.

 

Cloud Free Trial

Try Talend Cloud free for 30 days.

Tutorial

Introduction to Talend Open Studio for Data Integration.

Definitive Guide to Data Integration

Practical steps to developing your data integration strategy.

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.