From RPTools Wiki
Jump to navigation Jump to search

REST.get() Function

 Note: This function can only be used in a Trusted Macro

Introduced in version 1.5.0
Perform an HTTP get request to the specified URL to retrieve a resource or information.


REST.get(url, getFullResponse)
REST.get(url, headers, getFullResponse)


  • url - String containing the URL to the resource or collection of resources.
  • getFullResponse - Boolean (0:1). Optional. Set true(1) to get full response.
  • headers - JSON object. Optional JSON headers.


HTTP response as JSON (if full response) or server response, usually JSON but can be XML, HTML, or other formats.


Get the specified user.
[h: baseURL = ""]
[h: path = "/api/users/2"]

[h: response = REST.get(baseURL + path, 0)]

Response: [r: baseURL + path]
[r: json.indent(response, 2)]


[h: response = REST.get(baseURL + path, 1)]

Full Response: [r: baseURL + path]
[r: json.indent(response, 2)]


{"data": {
  "id": 2,
  "first_name": "Janet",
  "last_name": "Weaver",
  "avatar": ""

Full Response: 
  "status": 200,
  "headers":   {
    "access-control-allow-origin": ["*"],
    "cf-ray": ["4b9244475b1b5432-LAX"],
    "content-type": ["application/json; charset=utf-8"],
    "date": ["Sun, 17 Mar 2019 22:05:09 GMT"],
    "etag": ["W/\"89-bSBFK27ZbQL+K8fMuJn/jZrcUuk\""],
    "expect-ct": ["max-age=604800, report-uri=\"\""],
    "server": ["cloudflare"],
    "set-cookie": ["__cfduid=d5f84a1d88f4b568cd9547d6f76b1712b1552860309; expires=Mon, 16-Mar-20 22:05:09 GMT; path=/;; HttpOnly"],
    "x-powered-by": ["Express"]
  "body": {"data":   {
    "id": 2,
    "first_name": "Janet",
    "last_name": "Weaver",
    "avatar": ""

Simple Syrinscape Example

From the Syrinscape forums.

[r: REST.get('')]
See this Syrinscape Online page for more info.

See Also