Undelete an asset
This article explains how to undelete an asset using the API. If you only want to undelete an asset, the simpler approach is to search for the asset and delete it from the Asset Detail page in the application's user interface.
Deleted is just one system-defined asset state. When you have the asset's OID Token, undelete is the same as setting any other asset state via the Undelete
operation. However, since the UI and the API will both hide deleted assets by default, there are some special steps to find a deleted asset.
Getting Started
- Have an HTTP Client.
- Obtain an API token.
Step 1: Query for Deleted Assets
Normally, we could use the asset state in a query to reduce the set of items we worry about. For example, send an HTTP GET with where
parameter of AssetState='0'
and a modest page
parameter to prevent returning too many results.
<Server Base URI>/rest-1.v1/Data/BaseAsset?where=AssetState='0'&page=100,0
However, deleted assets are automatically filtered from query results so trying the same thing with AssetState='255'
will return no results. We need to use the special filter token for deleted, IsDeleted='true'
.
<Server Base URI>/rest-1.v1/Data/BaseAsset?where=IsDeleted='true'&page=100,0
Step 2: Execute Undelete
Once we have found a specific asset to undelete, we send an HTTP POST to the rest-1.v1/Data endpoint. The request has no body and uses the op
parameter set to Undelete
.
POST /VersionOne/rest-1.v1/Data/Timebox/14636?op=Undelete HTTP/1.1
Host: www14.v1host.com
Content-Type: application/xml
The response should be similar to the following.
<?xml version="1.0" encoding="UTF-8" ?>
<Asset href="/v1sdktesting/rest-1.v1/Data/Timebox/14636/22331" id="Timebox:14636:22331" />
The returned Asset
node indicates the asset was properly updated.