1
votes

Using Pentaho PDI 8.3.0

I am unable to use a parameter in a REST call within a transformation. What I've done is:

  • Create a transformation and given it a parameter called PAGE_NR with default value 1
  • Create a job
  • Call the transformation with parameter PAGE_NR = 1
  • In the transformation, set up a GET request to a REST API.
  • In the URL field, setup the call like http://myurl.com/foo/bar?page=${PAGE_NR}

When I call this from either SoapUI or a browser it works but it always breaks when running the job. It does not seem to translate this parameter into the value, but instead passes it exactly like mentioned above.

I need this parameter because of calling the same URL but with different results. I don't know the amount of pages up front but take care of that logic later in said transformation.

Working on Linux btw. I have tried different variations of calling the parameter but nothing seems to work.

1
If you run the transformation in Spoon and fill in a value for the parameter manually on the configure screen, what happens? Still having the literal ${PAGE_NR} in there normally means there is no variable/parameter defined with that name. - Cyrus
This is exactly what I've done. I ran the transformation in Spoon and make sure to provide a default value. - JustLudo
From the post, it sounds like you run it from a parent job, not directly running the transformation, that's why I asked. I would try to instead get the URL in a field in the row and use that in the REST step. It's easier to verify that your field is correct that way. - Cyrus
Ah, now I see. Well I have run both cases but I'm currently talking about the transformation as I run it standalone (no job here). I use the "Generate rows" to set the URL for the REST call and in it I set the string as mentioned above. If I replace the ${PAGE_NR} with it's hardcoded value of 1 the flow works perfectly. I have tried various versions that I could find (like $.PAGE_NR or ${"PAGE_NR"} ) but none seem to work. I verified that I gave the parameter a default value (CTRL-T and to the "Parameters" tab). - JustLudo
You mentioned this is going to be a mutating parameter, you're going to need to call this KTR from a KJB, and a variable to the parent Job through another KTR. I don't know if this happens in Linux, but in Windows it's quite commom that a number only variable is interpreted as Number and not String, so sometimes your number from the variable will come out as " 1" instead of "1", mind the black space before the number. - Cristian Curti

1 Answers

1
votes

With the information given in the comments, I am willing to make an educated guess:

The REST Client step does not perform variable substitution on the URL if it comes from a field in the stream. What you can do is insert a Calculator step before the REST step with the operation "Variable substitution on string A" with your URL field as Field A.

This should give you the desired URL with page number.