POST http://yourserver.com/services/remove ?q=<query> &ids=<comma-delimited asset ids> &folderPath=<folder to remove> &async=<true | false> |
What does it do?
Removes one or more assets, or folders including their content.
Log in requirement
Before being able to request information from Assets Server by using a GET request or make changes to the system through a POST request, a log in to Assets Server is required. For information about the available APIs for logging in, see Assets Server REST API - introduction.
POST requests only
This REST API only accepts POST requests, not GET requests. Also, the POST request needs to include a cross-site request forgery (csrf) token.
The csrf token is a unique code which, by including it in the request, also makes the POST request unique and therefore much more secure.
The csrf token is obtained by first logging in to Assets Server through a POST request. The response that is received will include the csrf token which can then be used in subsequent POST requests as a http header:
"X-CSRF-TOKEN: <some_csrf_token>"
For more information including examples, see Assets Server REST API - Performing a POST request with a csrf token.
Parameters
q | A query that matches all assets to be removed. Be careful with this and make sure you test your query using a search call to prevent removing assets that you did not want to be removed. |
ids |
A comma-delimited list of asset ids to be removed. |
folderPath |
The folderPath of the folder to remove. The last folder in the argument is removed, along with all subfolders and all assets. |
async |
When true, the process will run asynchronous in the background. The call will return immediate with the processId. Optional. By default, the call waits for the process to finish and then returns the processedCount. |
Note: It is not possible to combine the ids , q and folderPath parameters. When multiple parameters are provided, only one is used in the following priority:
|
Return value
The operation returns a JSON object with the following properties:
processedCount | Number of assets that were processed by the operation. |
errorCount | Number of errors that occurred. |
canceled | true or false depending on if the operation was canceled on the Server status page in the Management Console. |
If called with async=true, the operation returns a JSON object with the following properties:
processId | Unique id of the process that was started. |
If the operation fails, a JSON error object is returned.
Example
Remove by ids
remove http://demo.assets-server.com/services/remove ?ids=5LMAQTW9qfhANn7f6JJVpl,E8MJ7tLJaUM8cY2eeWYxEu |
Remove by query
The following removes all assets imported more than one year ago.
remove
http://demo.assets-server.com/services/remove ?q=assetCreated:[* TO NOW-1YEAR] |
Remove a complete folder
The following removes a complete folder, including subfolders and all contained assets.
remove
http://demo.assets-server.com/services/remove ?folderPath=/Demo Zone/Images |
Revisions
- 2 December 2024: Updated section 'Return value' by adding the 'canceled' property.
Comment
Do you have corrections or additional information about this article? Leave a comment! Do you have a question about what is described in this article? Please contact Support.
0 comments
Please sign in to leave a comment.