Setting the Resource Location

A REST resource location is the second part of the URI and it specifies which resource of the API is to be accessed.

When instantiating a JadeRestRequest object, you need to provide a resource of the API as a parameter to the create method. For example, consider the following URI from the Swagger Petstore example REST API.

The /pet/3 part is the specific resource we are accessing, which is the resource part we need to provide in the create method of the JadeRestRequest object, as follows.

client := create JadeRestRequest("/pet/3");

In this case, part of the resource location is a parameter to let the server know which of the Pet resource objects we are trying to access, specifically the Pet with an ID equal to 3. We can make this more readable by using a parameter name in the create method and then using the addURLSeg method of the JadeRestRequest class, as follows.

client := create JadeRestRequest("/pet/{petID}");
client.addURLSeg("petID", "3");