tRest Client Query Parameter

Highlighted
Five Stars

tRest Client Query Parameter

How to pass a Column value from a table in a tRestClient as Query Parameter?
This way I could get a different response based on each input row from the source.


Accepted Solutions
Community Manager

Re: tRest Client Query Parameter

In the "Value" field of the "Query Parameters" box in your tRestClient, simply add your row.column name. For example, if your row is "row1" and your column is "myData", you would add.....

row1.myData

All Replies
Community Manager

Re: tRest Client Query Parameter

In the "Value" field of the "Query Parameters" box in your tRestClient, simply add your row.column name. For example, if your row is "row1" and your column is "myData", you would add.....

row1.myData
Five Stars

Re: tRest Client Query Parameter

On the same line, I'm trying to pass multiple values in a Query parameter as mentioned in the attached screenshot.
Although it doesn't throw error, I'm getting a Response only for one value (Like 91108) of the query parameter.

Is there any way to pass multiple values?

MUL_QUERY_PARAM.jpg

Community Manager

Re: tRest Client Query Parameter

This very much depends upon how the server is configured I think. Query params are essentially just params that look like this....

https://myserver.com/resource-name?param1=value1&param2=value2

If your attempt has just actioned the first ID in your list, you may need to try in a couple of different ways. First of all, test your call using the syntax above and do not specify the query params in the query parameters box. So your URL would look like this (assuming the beginning of the url matches this "https://myserver.com/resource-name")....

https://myserver.com/resource-name?action=list&details=All&ids=91053,91056,91085,91091,91108

I suspect you will get the same result from the above as you did by using the Query Parameters box, but I may be wrong. The next thing to test is sending an "ids" param for each id. For example....

https://myserver.com/resource-name?action=list&details=All&ids=91053&ids=91056&ids=91085&ids=91091&ids=91108

If the above works, then you should be able to convert the above into the same thing but using the Query Parameters box in the component.

Five Stars

Re: tRest Client Query Parameter

1. Option 1: As mentioned, I'm getting multiple responses when I use a different tool like Postman for API call 
?action=list&details=All&ids=91053, 91056.
But in Talend, I'm getting the last id response only (91056). Why is it different from other API calls?
2. Option 2 : I tried the same in Talend with different values in different parameter, but I still end up getting one response ( for id=91017)

 multiple ids.jpg

Community Manager

Re: tRest Client Query Parameter

When you say multiple responses, do you mean multiple messages back or do you mean a single message with multiple records? If it is the second, then this might be bug. However, if it is the first, then you can recreate this by simply calling the tRestClient for each of the ids.

 

Five Stars

Re: tRest Client Query Parameter

Thanks, Rhall for your response.

Calling RestClient for every single ID is taking a very long time ( more than 10 hours for 1500 ids).
That's the reason why we are looking to have a single API call with multiple IDs as an alternative.

Community Manager

Re: tRest Client Query Parameter

OK. But does the API return a single message with data for all of the IDs or does it return a different message for each ID? I'm trying to figure out why there is a difference in behaviour between  your other tool and Talend. 

 

Also, have you tried using another REST component? Maybe the tRest component. You will not have the option of the Query Parameters box, but these can be set in the URL. 

 

It is quite difficult to debug issues with web services when you do not have access to them or the documentation. I suspect that you cannot offer access to the service, but maybe you can post a link to some documentation?

Nine Stars JR
Nine Stars

Re: tRest Client Query Parameter

Sorry to jump in here. Can it be that you are processing the output directly in e.g. a tExtractJSONField component after the tRESTClient component? In this case, only the last record in your response would be processed in case you have set the loop path incorrectly - this would explain why you always only get the last record.

When you put a tLogRow component directly after the tRESTClient component, what does the output say (status, body, string)? Does the column "string" contain more than one record?

Furthermore, you say that in Postman everything looks OK. Which settings do you choose when you are using Postman (Content Type, HTTP method). Can you please provide a screenshot of this as well?

In your initial request you indicate that you provide the values like this: "91053, 91056". I assume, you have tried to remove the spaces before the separators ("91053,91056"), correct?

Community Manager

Re: tRest Client Query Parameter

Great call @JR. I'd assumed that the output was being viewed using a tLogRow (as that is always how I work with services when building). I thought I had mentioned that, but I hadn't. Please feel free to jump in whenever and wherever :-)

Five Stars

Re: tRest Client Query Parameter

Thank you JR and RHall for your responses.
Yes,I could now get the response from TRestClient as multiple records and could pass multiple values using tJava from the table result. 

 Column "string" contains more than one record and I had to convert that as a Document type and set the loop element appropriately to get the result. 

But , I'm still not getting the output as expected to load into a table as I have nested/recursive loop and multiple loop XML structure like below:
<A_LIST>
             <M_LIST>

                  <B>

                       <ID><![CDATA[828282]]></ID>
                       <URL><![CDATA[xxxx]]></URL>

                  </B>

                   <B>

                        <ID><![CDATA[14141]></ID>

                        <URL><![CDATA[xxxxxxx]]></URL>

                    </B>

             </B_LIST>

              <C_LIST>

                  <C>

                       <ID><![CDATA[989898]]></ID>
                       <URL><![CDATA[xxxx]]></URL>

                  </C>

                   <C>

                        <ID><![CDATA[181818]></ID>

                        <URL><![CDATA[xxxxxxx]]></URL>

                    </C>

             </M_LIST>

             <M_LIST>

             .

             .

             </M_LIST>

<A_LIST>

I got to know that tXML Map currently doesn't support nested/recursive loop and I had to use tHMap instead.
Any pointers on how to define the loop element in tHMap and process the XML data to table?

Calling Talend Open Studio Users

The first 100 community members completing the Open Studio survey win a $10 gift voucher.

Start the survey

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

Self-service Talend Migration: Moving from On-Premises to the Cloud

Move from On-Premises to the Cloud by following the advice of experts

Read Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read