PUT Method Example

A PUT request is used to replace an existing resource with a new one. It functions in a similar way to a POST request, except that an existing resource will be overwritten on the REST service.

putPet();
constants
    Endpoint = "https://petstore.swagger.io/v2";
    Path = "/pet";
vars
    client : JadeRestClient;
    response : JadeRestResponse;
    request : JadeRestRequest;
    pet : Pet;
begin
    client := create JadeRestClient(Endpoint) transient;
    request := create JadeRestRequest(Path) transient;
    create pet transient;
    pet.id := 314;
    pet.name := "Not Fluffy";
    pet.status := "available";
    request.dataFormat := request.DataFormat_JSON;
    request.addObjectParam(pet, Pet);
    create response transient;
    client.put(request, response);
    // We should get a 200 - Success.
    write response.statusCode;
epilog
    delete client;
    delete response;
    delete request;
    delete pet;
end;