Five Stars

How do I get the URL passed in the tRESTClient

Hi Talend Community,

 

I have a rest service using tRESTClient that send parameters (header and body) via a REST GET call.

How can I see the URL being executed in its total string format.

tLogRow only shows the result set returned

 

Thanks

  • Big Data
  • Data Integration
  • ESB
18 REPLIES
Ten Stars

Re: How do I get the URL passed in the tRESTClient

Is your URL hard coded? If so, you should probably change that. Add it to a context variable. If you do that, you can change it without having to change the job and recompile it. You can also make use of the context variable in other areas quite easily.  

Rilhia Solutions
Five Stars

Re: How do I get the URL passed in the tRESTClient

Hi 

 

The URL is not hardcoded, if I understand correctly - or is there something specific your are referring too?

 

Please see my config in the original post (screen captures).

Thank you 

Five Stars

Re: How do I get the URL passed in the tRESTClient

How can I add the context variable to display the URI on execution?

Ten Stars

Re: How do I get the URL passed in the tRESTClient

You can use a tJava.....

System.out.println("My URL is: "+context.URL);

Or you can add it to a column in a tMap (for example) and use a tLogRow

Rilhia Solutions
Five Stars

Re: How do I get the URL passed in the tRESTClient

I placed the tJava with code specified after my tRestClient and got :

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
	URL cannot be resolved or is not a field

URI.PNG

Ten Stars

Re: How do I get the URL passed in the tRESTClient

Ah I see. Replace the tJava with a tMap. Map the input columns to the output. Add an output column and put.....

context.URL

.....in the new column. Keep the tLogRow connected (refresh the schema) and you will see the URL printed by the tLogRow

Rilhia Solutions
Five Stars

Re: How do I get the URL passed in the tRESTClient

I might be misunderstanding

 

But here is my tMAP settings

tmap.PNGI am not getting the URL in the output

Thanks

Ten Stars

Re: How do I get the URL passed in the tRESTClient

You have to add it. By the way, you have duplicated all of your output columns

Rilhia Solutions
Five Stars

Re: How do I get the URL passed in the tRESTClient

I did add the variable, but no success

 

Do you perhaps have an example to better articulate?

Thanks

 

Ten Stars

Re: How do I get the URL passed in the tRESTClient

I don't have an example to hand, but I can talk you through exactly what you have to do...
1) Create a new context variable called "URL". Do this in the "Contexts" tab below your job.
2) Assign the URL context variable the url that you currently have in your tRestClient. Replace the URL there with the new context variable.
3) In your tMap click on the output table (on the right) so that it turns yellow. At the bottom of the screen you will see the schema. Click the green + (at the bottom of the page on the right) and add a String column called "URL" (or anything you think is appropriate).
4) You will see this new column appears in the output table (which turned yellow). Add.....

 

context.URL

... to the column called URL. Do not use quotes.

 

Now when you run your job you should see the URL column appear in the tLogRow with the other output columns.

Rilhia Solutions
Five Stars

Re: How do I get the URL passed in the tRESTClient

Thank you got the URI, 

Is there a way to see the headers also?

 

Ten Stars

Re: How do I get the URL passed in the tRESTClient

Are these dynamic headers or are you hardcoding them?

Rilhia Solutions
Five Stars

Re: How do I get the URL passed in the tRESTClient

I have defined the items as below, but still do not get the URI

tMap

tmap.PNG

context:

conext.PNG

 

Ten Stars

Re: How do I get the URL passed in the tRESTClient

I explained how to do this in my other post. Follow the instructions step by step. Go to the section where I talk about creating a column in the yellow output table

Rilhia Solutions
Five Stars

Re: How do I get the URL passed in the tRESTClient

Hard coded headers,

 

But I think I have a problem in translation:

I have a Authorization tag that needs to contain: Token token="729f70f8-67dd-86b9-0296-23d3a387a19e"

I have it configured as such: 

Header.PNGI need to see the complete URI output to ensure Talend is parsing the parameters correctly and sending the correct URI 

Ten Stars

Re: How do I get the URL passed in the tRESTClient

Your token is almost certainly formatted wrong and this is a different question. It is not a great idea to ask further questions on the same thread because it leads to useful answers being lost.

 

Raise another question about the headers and include the specification you are working from. We will need to see the requirements of the web service you are using. Trying to solve this question without seeing this will be like literally searching for a needle in a haystack..... in a collection of fields in a random country.  

Rilhia Solutions
Five Stars

Re: How do I get the URL passed in the tRESTClient

will do thanks

 

Five Stars

Re: How do I get the URL passed in the tRESTClient

I have create as I understood your explanation but still have no output

 

 tmap.PNG