Add Server Variables for Service Connections

After creating a service connection, you can go to the Servers tab and edit the server's instance URL and add server variables.

Note:

For service connections created after the 23.10 release, server variables must be updated from the backend associated with the service connection. For more information, see Add Server Variables for Backends.

When you enter a valid URI template expression, such as {version}, in an instance URL, a server variable will be created automatically and displayed in the Server editor's Server Variables section. You can also create, edit, or reorder a list of variables. A default value must be set for each server variable.

Let's take a look at how this works, using https://restcountries.com/v3.1/lang/german as an example:
  1. The server instance URL can be represented as https://restcountries.com/{version}/lang.

    Here, there's just one server variable, {version}, which has a default value of v3.1, as shown:Description of server-variable-example.png follows
    Description of the illustration server-variable-example.png

  2. The endpoint is /{language}.

    Here, language is a path parameter, because it's a part of the endpoint path. It can't be a server variable, in this example, because it's outside the instance URL. Its default value is german and its type is string.

  3. The full URL becomes https://restcountries.com/{version}/lang/{language}.

    After substitution (v3.1 for the server variable {version} and german for the language path parameter), this represents the instance URL we started with, https://restcountries.com/v3.1/lang/german.

Here's how you can add or change a variable (or multiple variables) in a server URL:
  1. Open the Servers tab of the service connection.
  2. Click Edit Editto the right of the server instance to which you want to add a new server variable (or modify an existing one) to the instance URL.
    The Edit Server dialog is displayed.
  3. In the Instance URL field, add a variable where one is needed.
    For example, you may want to replace a version number in the URL, such as "1.2" with the variable {version}. After you do this, you'll see the variable you added to the URL displayed in Server Variables, below the instance URL's Description field. The variable you added is shown in the Name field.
  4. Enter a description in the Description field and set the default value in the Default field.
    Click Done if you are finished or click + Add Value to add another value. To create a list with multiple values, click Menu Menu and select Create Value List. Then, after adding values, use the Up control or Down control controls to set the default value or reorder the list of values. The default value will be the one at the top of the list. You can use Delete Delete to discard values you don't need.
  5. Add another variable in the URL, if needed.
    Note that you must set a value for each variable you define. If you don't, you'll see a message indicating that a value is required. Enter the default value and click Done.
  6. Click Save.

Tip:

There's a new Server Variables tab in the Endpoint editor's Test tab. You can use this tab to test the value of server variables when you're testing an endpoint. With a defined value list, you can effectively change the URL and test each version. The process for using this functionality is very similar to what was described here.