Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tRest HTTP Body in PUT Method

Hi Guys, Can anyone guide me on the below requirement.

 

I have a better understanding of GET & DELETE methods and struck with PUT. I have to update two attributes(fields) in my client console.

I have a spreadsheet with four columns, ID, Name, Name2 & Name3. The requirement was to update Name3 & Name4 for each IDs. I will pass ID in the URL to update records (https://aaa/bbb/cccc/2.0/dddd/ffff/1010), and I have done this before. For PUT method, we required to pass HTTP Body in tRest. And it's mandatory to include ID & Name here, since those are unique matches to update Name3 & Name4. (pl see below JSON)

 

{
"name": "Test1",
"id": "1010",
"name3": "test123",
"name4": "test456"
}

 

Please guide me to achieve this by providing components and flow?

 

Thanks in Advance!!

KarthI

Labels (1)
1 Solution

Accepted Solutions
nfz11
Creator III
Creator III

The tRestClient component is better suited for this as it has more features than tRest.  You would construct the JSON body however you want before the tRestClient, e.g. with a tWriteJSONFields or tJavaRow component.  Declare a String schema variable called 'string' that contains the body.  tRestClient will read the body from here.  Select the 'PUT' method in the tRestClient and fill out any other variables you need.  You can use variables in the URL and relative path fields in tRestClient so you can dynamically build your REST URL with the ID, for example.  Set the content type to JSON.

 

See here for the full documentation on tRestClient.

https://help.talend.com/reader/hCrOzogIwKfuR3mPf~LydA/~V42EBQClKxKQghNvzHF1g

View solution in original post

6 Replies
nfz11
Creator III
Creator III

The tRestClient component is better suited for this as it has more features than tRest.  You would construct the JSON body however you want before the tRestClient, e.g. with a tWriteJSONFields or tJavaRow component.  Declare a String schema variable called 'string' that contains the body.  tRestClient will read the body from here.  Select the 'PUT' method in the tRestClient and fill out any other variables you need.  You can use variables in the URL and relative path fields in tRestClient so you can dynamically build your REST URL with the ID, for example.  Set the content type to JSON.

 

See here for the full documentation on tRestClient.

https://help.talend.com/reader/hCrOzogIwKfuR3mPf~LydA/~V42EBQClKxKQghNvzHF1g

Anonymous
Not applicable
Author

Thanks, dude. Its worked but still, I am facing runtime error. I have googled a bit and found may be a chance of missing Environment variables(JAVA PATH) in my machine, but files(jdk & jre) advanced versions exist. 

Attached the screenshot for reference. Please advice.

 

0683p000009M5Md.jpg

nfz11
Creator III
Creator III

Did you move your project around or put it in a new folder?  That looks like Talend cannot find the project at the location where you are trying to run it.

Anonymous
Not applicable
Author

My Project inside the workspace, but still it's showing the error.

 

0683p000009M5Mi.jpg

nfz11
Creator III
Creator III

You could try building the project again or restarting Studio.

Anonymous
Not applicable
Author

Hi, The above issue has been fixed. But now we are facing the issue in tRESTClinet, can you please help us to fix the below.

 

Error Detail:

0683p000009M5Ms.jpg

0683p000009M5Mx.jpg