GET Method Example

A GET request is used for obtaining a resource.

It is not usual for any HTTP body to be required for a GET request, but the REST service will typically return the requested resource in the response body on a successful request.

getPet() : Pet;
constants
    Endpoint = "https://petstore.swagger.io/v2";
    Path = "/pet/{petId}";
vars
    client : JadeRestClient;
    response : JadeRestResponse;
    request : JadeRestRequest;
    objs : ObjectArray;
begin
    client := create JadeRestClient(Endpoint) transient;
    request := create JadeRestRequest(Path) transient;
    request.addURLSeg("petID", "1");
    create response transient;
    client.get(request, response);
    create objs transient;
    response.deserialize(Pet, objs);
    return objs.first.Pet;
epilog
    delete client;
    delete response;
    delete request;
    delete objs;
end;