Hello collective,
I am trying to use the REST2 API to get and update information about RT groups, but am struggling to find documentation or good examples for how to do it. My dev server is on RT 5.0.7.
I can use the groups endpoint, like this test:-
CURL=/usr/bin/curl
RT_URL='https://hostname'
RT_TOKEN='<deleted>'
$CURL --request POST \
--header "Authorization: token $RT_TOKEN" \
--no-buffer \
"${RT_URL}/REST/2.0/groups"
But this lists all groups including role groups, so returns a huge list:
{
"count" : 20,
"total" : 81585,
"per_page" : 20,
"items" : [
{
"type" : "group",
"_url" : "https://hostname/REST/2.0/group/87",
"id" : "87"
},
...
],
"next_page" : "https://hostname/REST/2.0/groups?page=2",
"pages" : 4080,
"page" : 1
}
The REST2 documentation suggests this:-
Groups
GET /groups?query=<JSON>
POST /groups
search for groups using L</JSON searches> syntax
POST /group
create a (user defined) group; provide JSON content
GET /group/:id
retrieve a group (including its members and whether it is disabled)
PUT /group/:id
update a groups's metadata (including its Disabled status); provide JSON content
DELETE /group/:id
disable group
GET /group/:id/history
retrieve list of transactions for group
But then gives no hints on what you need to supply for query
in the JSON search to limit the results only to User Defined Groups.(Equivalent of $Groups->LimitToUserDefinedGroups()
) in the perl API.
Other scripts I have work for example to for a tickets query:
$CURL ${RT_URL}/REST/2.0/tickets --request POST \
--header "Authorization: token $RT_TOKEN" \
--no-buffer \
--data-binary '
[
{ "field": "Status",
"value": "open"
},
]'
I also want to get customfields from the group, which in Perl API is something like:
my $values = $Group->CustomFieldValues('cust_id');
while (my $value = $values->Next) {
my $cust_id= $value->Content;
print "Cust ID: $cust_id\n";
}
Any pointers how to do it in the REST2 API would be much appreciated.
Thanks.