Getting started
The format of the query language is either JSON or YAML. For simplicity, this example starts with a basic query and builds from there.
Select the Id
and Name
for all communities as a flat list. The object representing the query is called ViewConfig, as it defines a particular view, which is a selection of the data. The object containing the graph part of the query is called Resources.
The following example shows the Community
entity along with its Id
and Name
properties.
- JSON
- YAML
{
"ViewConfig": {
"Resources": {
"Community": {
"name": "Communities", <---\
"Id": { "name": "community id" }, ---- a node can (or must) have a name. Thus the community own 'name' property must be uppercased to avoid conflicts.
"Name": { "name": "community name" } <---/
}
}
}
}
---
ViewConfig:
Resources:
Community:
name: "Communities" <---\
Id: ---- a node can (or must) have a name. Thus the community own 'name' property must be uppercased to avoid
name: "community id"
Name: <---/
name: "community name"
- Entity and property keys are case insensitive, so
Community
andId
can be written in any case. - The other keys are case sensitive. For example,
ViewConfig
,Resources
orName
must be written as shown. - If a property is spelled out the same way as a reserved keyword, you must use a different casing than the reserved key. For example, you use lowercase
name
as the node name and capitalizedName
as the community name.
Test the API
To test the API, use a REST client, such as the Postman plugin for Chrome. Many output formats are available, but the JSON tree is the format that most resembles the query.
This example uses the following endpoint on the OutputView resource:
{{domain}}/rest/2.0/outputModule/export/json
Use a POST call with the following body.
- JSON
- YAML
{
"ViewConfig": {
"Resources": {
"Community": {
"Id": {
"name": "community id"
},
"Name": {
"name": "community name"
}
}
}
}
}
---
ViewConfig:
Resources:
Community:
Id:
name: "community id"
Name:
name: "community name"
Remember to set the content type header.
- JSON
- YAML
'Content-Type': 'application/json'
'Content-Type': 'application/x-yaml'
The output is formatted as an array of communities.
{
"view": {
"Community0": [
{
"communityId": "c87f166e-041f-4bea-8ff7-c1ffbab2ceeb",
"communityName": "First Community"
},
{
"communityId": "86a745f5-7e87-4851-a107-a3a272ccea0b",
"communityName": "Second Community"
}
]
}
}
You can use the ViewConfig queries with the following endpoints:
{{domain}}/rest/2.0/outputModule/export/{{xml | json}}
{{domain}}/rest/2.0/outputModule/export/{{xml | json}}-file
{{domain}}/rest/2.0/outputModule/export/{{xml | json}}-job