Skip to main content

Using context variables in REST endpoint URLs in Data Services

Context variables are supported in REST service provider and consumer endpoints in Data Services. This allows you to run multiple interacting services locally in Talend Studio, while having the endpoints contextualized so that you can deploy services to various environment using a different context.

For more technologies supported by Talend, see Talend components.

You can use context variables in the endpoint URL of tRESTRequest, tRESTClient and cREST, either an absolute or relative path.

For example, the following context variables are defined in Talend Studio.

Context Value

context.full_a

http://localhost:8090/services/customers

context.full_b http://localhost:8090/customers
context.full_c http://localhost:8090/any/customers

context.url_a

/customers

context.url_b

/services/customers

context.port_a

8090

context.port_b

8091

If you specify the endpoint URL with the context variables, the service will be exposed at the following addresses.

Endpoint Studio Runtime Microservice(app/docker)

context.full_a

http://localhost:8090/services/customers

http://localhost:8090/services/customers http://localhost:8090/services/customers
context.full_b http://localhost:8090/customers http://localhost:8090/customers http://localhost:8090/customers
context.full_c http://localhost:8090/any/customers http://localhost:8090/any/customers http://localhost:8090/any/customers

context.url_a

http://localhost:8090/customers http://localhost:8040/services/customers http://localhost:8065/services/customers

context.url_b

http://localhost:8090/services/customers http://localhost:8040/services/customers http://localhost:8065/services/customers
"http://localhost:"+ context.port_b + context.url_b http://localhost:8091/services/customers http://localhost:8091/services/customers http://localhost:8091/services/customers

context.url_a + "/rest"

http://localhost:8090/customers/rest http://localhost:8040/services/customers/rest http://localhost:8065/services/customers/rest

"http://localhost:8090" + context.url_a + "/" + System.getProperty("user.name")

http://localhost:8090/customers/<DynamicOSLoginUserName> http://localhost:8040/services/customers/<DynamicOSLoginUserName> http://localhost:8065/services/customers/<DynamicOSLoginUserName>
Information noteNote: If the endpoints contains a Java code like System.getProperty, user should set this properties before running the bundle in Talend Runtime or Microservice. Otherwise there will be an error as the properties are missing.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!