URL Path Variables

Introducing URL Path Variables

In the context of systems integration, URL path variables are placeholders in a URL that represent dynamic data or parameters that can be specified at runtime. These variables allow the same URL endpoint to be used for multiple operations, with the path variables specifying the specifics of the desired operation. For example, in a URL endpoint for retrieving user information, a path variable might be used to specify the unique identifier of the user whose information is being requested.


In this way, URL path variables provide a way for systems to dynamically specify the details of an API operation, allowing for more flexible and reusable API endpoints, while still ensuring that the correct resource and operation is specified.


Dynamic URLs: A Path Variable can be used to handle template variables in the Request URI mapping. When calling a REST API through a URL that has a dynamic component, it is possible to embed a variable in the URI in the Context Name in the integration.


Note: The configuration of a variable on an Inbound Request is different from the configuration for a variable on an Outbound Request.

Inbound API Request Variables

To include the variable in the path – wrap the variable in the path with {}. For example, if you have a URL where part of the URL changes such as the API version your URL might look like this: http://inboundservice/v1/request

You would configure the Context Name as “inboundservice/{API_Version}/request” and the ‘API_Version’ (with the value of ‘v1’ in the example) variable must be set to be unmarshalled from the ‘Header’. Depending on the use case, you can have more than one path variable in a request URI:


Example Incoming: /variableContext/{variable1}/{variable2}/request


The screenshot below shows how the Context Name should be constructed for Inbound API Requests containing variables.


Outbound Connector Request Variables

You need to specify the variable to use from the GLU Object model and you need to specify that it must be inserted into the Header (URL), using the following format ${header.variableName}. Once the Context Name is setup, in the Outbound Request parameters, the variable must be marshalled to the header.


Depending on the use case, you can have more than one path variable in a request URI:


Example Outgoing: /variableContext/${header.variable1}/${header.variable2}/request


Note: For Outbound Requests, the prefix ‘header.’ must be used with each variable. Screenshot below shows how the context name needs to be constructed for Connector outbound APIs containing variables.


Some URL Path Variable examples below:


Example 1 – Single URL parameter:

http://specialservice/variableContext/KLM/request
http://specialservice/variableContext/BritishAirways/request
http://specialservice/variableContext/KenyanAirways/request
http://specialservice/variableContext/Emirates/request

You can then define the Context Name as follows:

variableContext/${header.varAirline}/request 


Example 2 – Variable and a query:

/${header.variable}/something/?key=value , you need to marshall the value of the query to header.

http:/x.y/specialservice//${header.variable}/Lufthansa/?key=${header.value}


Example 3 – Variable and multiple query values:

If you have values after the query with “&” (ampersand), use the HTML format: &

/PinlessRecharge?connectionsPerRoute=20&api_key=ugz27d7e4enfqcq8hkgfqqjs

Was this article helpful?

Related Articles

Fill the form and we’ll contact you shortly

    I agree with

    cookies
    We uses cookies to make your experience on this website better. Learn more
    Accept cookies