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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Fifteen Stars

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.

 

Rilhia Solutions
1 REPLY
Fifteen Stars

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.

 

Rilhia Solutions