All Classes Namespaces Functions Variables Groups Pages
RestClient Module

# RestClient Introduction

The RestClient module provides an API for calling REST services.

To use this module, use `"%requires RestClient"` in your code.

All the public symbols in the module are defined in the RestClient namespace.

The main classes are:

- RestClient: this class provides the REST client API

The RestClient class can support three methods of data serialization:

- `"json"`: using the `"json"` module; messages bodies are encoded using JSON
- `"yaml"`: using the `"yaml"` module; message bodies are encoded using YAML
- `"xml"`: using the `"xml"` module; message bodies are encoded using XML-RPC value encoding

If none of the above modules can be loaded by the RestClient module, then the RestClient module will fail to initialize.

For maximum compatibility with other REST solutions, the `"json"` encoding method is the default when no other encoding method is chosen and the `"json"` module is available.

Example:
  #!/usr/bin/env qore
  %requires RestClient
  my RestClient $rest(("url": "http://localhost:8001/rest"));
  my hash $ans = $rest.get("orders/1?option=full");
  printf("%N\n", ans.body);

See example file `"rest"` in the examples directory for a more detailed example using this module