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

Highlighted
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.

 

Five Stars

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

Thanks for details, was helpful.

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register 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

APIs for Dummies

View this on-demand webinar about APIs....

Watch Now

6 Ways to Start Utilizing Machine Learning with Amazon We Services and Talend

Look at6 ways to start utilizing Machine Learning with Amazon We Services and Talend

Blog

Why Companies Move to the Cloud: 7 Success Stories

Learn how and why companies are moving to the Cloud

Read Now