Managing objects using REST
To manage objects in Xperience using the REST service, send requests using the POST, PUT or DELETE HTTP method to the appropriate URL — append the resource paths described below to the base URL of your REST service.
The base URL of the Xperience REST service is <administration application domain name>/rest. For example, if your administration application runs at http://localhost/Xperience, use http://localhost/Xperience/rest as the base URL of the service.
Object resource paths start with an object type value. To find the value for specific object types, open the System application in the Xperience administration interface and select the Object types tab.
Important: Do NOT use object requests to create, update or delete the pages of Xperience websites. See Managing pages using REST for information about working with pages.
Creating objects
HTTP method: POST
Resource format:
- /<object type> - creates a new object of the specified type.
- /<object type>/currentsite - creates a new object of the specified type and assigns it to the website running on the domain in the base URL.
- /<object type>/site/<site name> - creates a new object of the specified type and assigns it to the specified website.
- /customtableitem.<custom table code name> - creates a new data record inside the specified custom table.
- /bizformitem.bizform.<form class name> - creates a new data record inside the specified form.
Set the name and other fields of the new object in the data of the POST request. Both XML and JSON formats are supported for the data.
Important:
- The service automatically sets the system fields of the new object (such as the ID and timestamp fields).
- Creating multiple objects of the same type in a single request is not supported.
- You can create child or binding objects along with the primary object. When using the XML format for the data of such requests, enclose the data into the <data> element to ensure valid syntax with a single root element.
Examples
Creates a new user with the Editor privilege level and an empty password. Assigns the user to the site running on the domain in the base URL.
XML | JSON |
URL: ~/rest/cms.user/currentsite Data:
| URL: ~/rest/cms.user/currentsite?format=json Data:
|
Creates a new country object with a child state
XML | JSON |
URL: ~/rest/cms.country Data:
| URL: ~/rest/cms.country?format=json Data:
|
Creates a coupon code for a discount (order or free shipping) on a site with code name sitename
XML | JSON |
URL: ~/rest/ecommerce.couponcode/site/sitename Data:
| URL: ~/rest/ecommerce.couponcode/site/sitename?format=json Data:
|
Adds a new data record into the Sample table custom table
XML | JSON |
URL: ~/rest/customtableitem.customtable.sampletable Data:
| URL: ~/rest/customtableitem.customtable.sampletable?format=json Data:
|
Updating existing objects
HTTP method: PUT
Resource format:
- /<object type>/<id > -updates the object with the specified identifier (primary key ID).
- /<object type>/<code name> - updates the object with the specified code name. For object types with site bindings, always updates the object assigned to the site running on the domain in the base URL.
- /<object type>/site/<site name>/<code name or guid> - updates the object with the specified code name or GUID value on the specified website.
- /<object type>/global/<code name or guid> - updates the global object with the specified code name or GUID value.
- /customtableitem.<custom table code name>/<item id or guid> - updates the data record with the specified identifier (ID or GUID value) inside the given custom table.
- /bizformitem.bizform.<form class name>/<item id or guid> - updates the data record with the specified identifier (ID or GUID value) inside the given form.
Update the values of the object’s fields using the data of the PUT request. Both XML and JSON formats are supported for the data. Updating multiple objects in a single request is not supported.
Examples
Updates the email address of the administrator user
XML | JSON |
URL: ~/rest/cms.user/administrator Data:
| URL: ~/rest/cms.user/administrator?format=json Data:
|
Updates a data record of the sample Contact us form
XML | JSON |
URL: ~/rest/bizformitem.bizform.contactus/1 Data:
| URL: ~/rest/bizformitem.bizform.contactus/1?format=json Data:
|
Deleting objects
HTTP method: DELETE
Resource format:
- /<object type>/<id> - deletes the object with the specified identifier (primary key ID).
- /<object type>/<code name> - deletes the object with the specified code name. For object types with site bindings, always deletes the object assigned to the site running on the domain in the base URL.
- /<object type>/site/<site name>/<code name or guid> - deletes the object with the specified code name or GUID value from the specified website.
- /<object type>/global/<code name or guid> - deletes the global object with the specified code name or GUID value.
- /customtableitem.<custom table code name>/<item id or guid> - deletes the data record with the specified identifier (ID or GUID value) from the given custom table.
- /bizformitem.bizform.<form class name>/<item id or guid> - deletes the data record the specified identifier (ID or GUID value) from the given form.
URL examples:
- ~/rest/cms.user/53
- ~/rest/cms.country/usa
- ~/rest/cms.emailtemplate/site/samplesite/Blog.NotificationToModerators
- ~/rest/customtableitem.customtable.SampleTable/5
Deleting multiple objects in a single request is not supported. You need to send a separate DELETE request for each object.