URL Path Variables

Introducing URL Path Variables

In the context of systems integration, URL path variables act as dynamic placeholders within a URL. These placeholders represent changing data or parameters that can be specified at runtime. They allow a single URL endpoint to cater to multiple operations, with the path variables defining the specific details of each operation. For instance, in a URL used to retrieve user information, a path variable might indicate the unique identifier of the user whose data is requested. 

In this way, URL path variables offer a flexible approach to defining API operations, enabling endpoints to adapt to different scenarios while ensuring the correct resources are accessed.

  • Dynamic URLs: Path variables allow for dynamic specification of details within a URL, making it easier to reuse endpoints for different purposes.
  • Clarifying API Operations: By embedding path variables in URLs, the purpose of each API request becomes clearer and more explicit, aiding in communication and understanding.
  • Example Usage: Consider a scenario where a single URL endpoint, such as /users/{userID}, is used to retrieve user information. Here, {userID} serves as the path variable, dynamically representing the unique identifier of the user being queried.

Note: It is important to differentiate between setting up variables in inbound and outbound requests, as their configurations may vary depending on the direction of data flow within the integration setup. 

Inbound API Request Variables

When incorporating variables into the URL path, wrap the variable within curly braces {}. For example, if a portion of the URL, such as the API version, changes dynamically, the URL might resemble: http://inboundservice/v1/request.

When configuring the Context Name as "inboundservice/{API_Version}/request" and the ‘API_Version’, with the value of ‘v1’ in the example. The 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

When setting up variables from the GLU Object model to be included in the URL, specify the variable to be used and ensure it’s inserted into the Header (URL) using the format ${header.variableName}. Once the Context Name is configured, the variable must be marshalled to the header in the Outbound Request parameters.

In cases where multiple path variables are needed in the request URI, follow a similar structure:

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

Note: For Outbound Requests, the prefix ‘header.’ must be used with each variable. The 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

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