Qore RestClient Module Reference  1.3
 All Classes Namespaces Files Functions Variables Modules 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

Release Notes

RestClient v1.3

RestClient v1.2

  • allow the Content-Type header to be overriden in REST requests
  • added hdr args to REST methods
  • fixed a bug using the module when the yaml module is not available

RestClient v1.1

  • updated to use encode_url() before sending HTTP messages
  • add charset=xxx to "Content-Type" header in requests
  • fixed "Accept" header in requests

RestClient v1.0

  • the initial version of the RestClient module