Vision App Maker rules work with JSON through a set of operators and call HTTP APIs through the RestClient plugin. Inside a rule, JSON is an object that the rule builds and queries. It becomes text only once, at the boundary, when it is sent to a plugin.

How it works

A typical exchange with an external API follows five steps.

  1. Build the request with JsonObject and JsonArray.
  2. Serialize it once with JsonText.
  3. Send it with the RestClient plugin.
  4. Parse the response with JsonParse.
  5. Read values with JsonValue or JsonValues.

Types are kept at both ends: numbers stay numbers, booleans stay booleans and null stays null. The serializer handles escaping of quotes and diacritics.

JSON operators

OperatorResultBehavior
JsonObject(key, value, ...)JSON objectValues can be scalars, entities, lists or other JSON objects. Null() writes an explicit null. With duplicate keys, the last one wins.
JsonArray(value, ...)JSON arrayEach operand becomes one element. A single list operand becomes a nested array.
JsonText(json, [indented])JSON textCompact by default; with true, formatted for logs.
JsonParse(text)Queryable object or arrayEmpty or null text returns null. The result works with Len, Iterate, First and Index.
JsonValue(json, path, [default])Typed valueAccepts an object or JSON text. Returns the first match; the default covers missing paths.
JsonValues(json, path)Typed listReturns all matches; an empty list when nothing matches.
ToJson(CustomType)Object or arrayConverts a custom type value to JSON.

Paths

  • profile.age reads a property.
  • roles[0] reads an array element by index.
  • $[?(@.role=='UX Designer')].name filters an array of objects; @ is the current element, like CurrentValue.

Common patterns

  • List of entities to a JSON array: Iterate builds one JsonObject per element, and JsonText serializes the collection as an array. When member names match the API keys, JsonText(ToJson(List)) is enough.
  • Find an element by property: First with a JsonValue(CurrentValue, ...) condition suits values that come from a parameter. A JSONPath filter is shorter for fixed queries.

RestClient plugin

RestClient is a generic HTTP client with built-in authorization. It supports any HTTP verb and any content type. It returns the raw response; a 404 or 500 status does not raise an exception, and the rule decides what to do.

Calling it

The plugin takes HttpRequest(url, method, [body], [content type], [headers], [authorization], [timeout]). A rule calls it with CallPluginWithParams and passes headers and authorization as JSON text. The outputs are read by index:

OutputContent
#0HTTP status code (200, 404...)
#1Response body, as text
#2Response headers, as JSON
#3Success flag, true for 2xx statuses

A rule typically checks #0, then reads the body with JsonValue(JsonParse(#1), ...). For an unexpected status it can stop with Throw and a formatted message.

Request body by content type

Content typeBody
application/json (default)JSON text
application/x-www-form-urlencodedAn object with the form fields; the plugin does the URL encoding
multipart/form-dataAn object with fields and files; file content in Base64, from FileToBase64

Authorization

Authorization is a JSON object with a type field:

  • basic, with user name and password;
  • bearer, with a token;
  • apikey, with the header name and its value.

For other schemes, the rule sets the Authorization header directly through the headers parameter.

RestClient and MakeHttpCall

MakeHttpCall, a System plugin, sends a URL, method, JSON body and headers and returns the response. RestClient adds:

  • a correct Content-Type for each body;
  • form and file uploads;
  • the status code and response headers as outputs;
  • a timeout per call.