Rest - Contacts - Groups
Purpose
Used for creating, editing and deleting Groups from the Views system.
Base URL
https://app.viewsapp.net/api/restful/contacts/groups
Schema
https://app.viewsapp.net/api/restful/contacts/groups/schema(.xml|.json|.xsd)
Creating a group
Once you have created your data file, you can send it using the following:
curl --url <Base URL> -u<username>:<password> -H Content-Type:text/xml -X POST -d "<xml>"
If there is a problem with creating that record, you will get a response containing all the errors, plus a copy of the translated data you supplied.
If the record was created successfully, the service will return a complete record for the newly created record if the attribute id set as the newly created id.
Fetching a group
curl --url <Base URL>/<id> -u<username>:<password> -H Content-Type:text/xml
This will return an xml file similar to this
<?xml version="1.0" encoding="utf-8"?> <group id="100001"> <Name>Group</Name> ... <Created>2011-05-09 10:26:09</Created> <CreatedBy>a.user</CreatedBy> <Updated>2011-05-09 10:26:09</Updated> <UpdatedBy>a.user</UpdatedBy> <Archived>0000-00-00 00:00:00</Archived> <ArchivedBy></ArchivedBy> <GroupID>100001</GroupID> <TypeName>group</TypeName> </group>
Fetching multiple groups records in one call
It is possible to use the search endpoint to retrieve multiple records
curl --url <Base URL>/search?ids[]=xxx&ids[]=xxx&ids[]=xxx& -u<username>:<password> -H Content-Type:text/xml
Depending on how many you are fetching, you may need to use POST rather than GET
Searching for a group
curl --url <Base URL>/search?q=<query> -u<username>:<password> -H Content-Type:text/xml
- query - This is a text string to use to search for in the groups records
You can search for any field for a specific value by setting the field as a parameter. Please refer to the schema for fieldnames.
There are also a series of fields that you use -from and -to modifiers to express a range:
- Created - yyyy-mm-dd
- Updated - yyyy-mm-dd
- Archived - yyyy-mm-dd
Updating a group
curl --url <Base URL>/<id> -u<username>:<password> -H Content-Type:text/xml -X PUT -d "<xml>"
- id - The ID of the group
The XML should be in the same format as the create XML. However, you only need to supply fields that you wish to update. For example:
<?xml version="1.0" encoding="utf-8"?> <group id="100001"> <Name>Group</Name> </group>
The above would result in updating group 1000001's Name value
Archiving a group
curl --url <Base URL>/<id>/archive -u<username>:<password> -H Content-Type:text/xml -X PUT -d '<status>1</status>'
- id - The ID of the group
This will set the archive flag on a group. If you set the status to 0, then it will remove the archive flag.
Deleting a group
curl --url <Base URL>/<id> -u<username>:<password> -H Content-Type:text/xml -X DELETE
- id - The ID of the group
This should be used with great care as it will permanently delete a group record.