The OpenEdge.Net.URI class enables you to create HTTP URIs. The URI class constructor is overloaded, so there are a number of different parameters that you can pass. Typically though, you want to pass the following parameters:

  • The scheme (http or https)
  • The hostname or sitename
  • Optionally, a port number

The following example defines a base URI:

USING OpenEdge.Net.HTTP.*.
USING OpenEdge.Net.URI.

DEFINE VARIABLE oClient AS IHttpClient NO-UNDO.
DEFINE VARIABLE oURI AS URI NO-UNDO. 

oClient = ClientBuilder:Build():Client.
oURI = new URI('http', 'oemobiledemo.progress.com').
To append additional path segments to the base URI (which you need to do for most REST API endpoints), use the Path property:
oURI = new URI('http', 'oemobiledemo.progress.com').
oURI:Path = "/OEMobileDemoServices/rest/CustomerService/Customer".

Alternatively, you can use the Parse() method to turn a string into a URI object:

oURI = URI:Parse('http://oemobiledemo.progress.com/OEMobileDemoServices/rest/CustomerService/Customer').

Add query strings

A query string is a set of one or more parameters that, when passed to a REST API, filters the dataset returned by the API.

For example, to get records for customers in Finland, your URI path must include the parameter country=Finland in a query string:

http://oemobiledemo.progress.com/OEMobileDemoServices/rest/CustomerService/Customer?filter=Country='Finland'
The ? in the URI path indicates that a query string follows. Multiple queries can be passed using the & separator. For example, to select customers from Finland, who have 'DKP' as their sales representative, you would need a URI like this:
http://oemobiledemo.progress.com/OEMobileDemoServices/rest/CustomerService/Customer?filter=Country='Finland'&SalesRep='DKP'
To add a query to your URI object, choose from one of the following options:
  • Add a query string (using the AddQueryString() method). Use this option if you have a string comprising all the query parameters.
    oURI:AddQueryString("filter=Country='Finland'", false).
    The AddQueryString() method takes two parameters—the query string, which is a character string, and a logical (true or false) value that indicates whether the query string should be URL decoded1.
  • Add one or more queries by calling AddQuery() for each parameter. Use this option if you have many queries, some of which are populated by variable values.
    oURI:AddQuery("filter", "'Country=Finland'").
    oURI:AddQuery("SalesRep", "DKP").

Add path parameters

A path parameter is separated by slashes (/) in the URI. Unlike a query, which requires a key-value pair (Country=Finland), a path parameter requires only a value. The following is an example of a customer ID (1) being passed as a path parameter in the URI:
http://oemobiledemo.progress.com/OEMobileDemoServices/rest/CustomerService/Customer/1
To add a path parameter to a URI object, use AddPathSegment():
oURI = new URI('http', 'oemobiledemo.progress.com').
oURI:Path = "/OEMobileDemoServices/rest/CustomerService/Customer".
oURI:AddPathSegment("1").

API reference documentation

To view the complete list of methods that you can use on a URI object, refer to the OpenEdge.Net.URI documentation or see the OpenEdge.Net API Reference documentation.
1 URLs are encoded as per the IETF specification. URL decoding replaces '%' escape characters in the URL, if any exist.