Restore a Deleted Node in a Tree
This tutorial demonstrates how to restore a deleted node in a classifications tree. The steps include retrieving the current tip-version nodes, reimporting the complete tree structure with the deleted node restored, and verifying that the node is no longer marked as deleted in the new tip version.
Before You Begin
- Register an app.
- Acquire a 3-legged OAuth token with the
data:read,data:write, anddata:createscopes. - Verify that you have access to the relevant account and Forma project and that you have Project Administrator permissions.
- Find the relevant project ID by following the Retrieve a Project ID tutorial. In this example, assume the project ID is
f6a1e3b5-abaa-4b01-b33a-5d55f36ba047. - Find the tree ID you want to update. In this example, assume the tree ID is
0295f158-6f95-7fb0-b008-4cde506166ee.
Step 1: Get Current Tip-Version Nodes (Including Deleted)
Call GET tip version nodes with includeDeleted=true to retrieve the current nodes in the tree, including deleted nodes.
Use the response to identify the node you want to restore.
Request
Response
In this example, assume you want to restore the node with code ROOM-102. Note its node ID, 019ed520-d6ae-71c6-9b57-8c2db7e8f79a.
The response returns a flat list of nodes. In the next step, you will convert the flat list into a nested tree structure and restore the node in the hierarchy.
Step 2: Reimport the Tree With the Deleted Node Restored
To restore the node, use the tree ID (0295f158-6f95-7fb0-b008-4cde506166ee) to call POST trees:reimport.
Provide the complete desired tree structure in importData, including the deleted node. In this example, ROOM-102 is restored to the hierarchy.
To restore the original node (instead of creating a new node), include the same node ID and place it under the same parent in the hierarchy. If you omit the original ID, a new node is created instead of restoring the deleted node.
Do not send the flat list of nodes returned in Step 1. Reimport expects a complete nested tree structure.
Request
Response (201)
The tree has been reimported with the ROOM-102 node restored. In the next step, verify that the node is no longer marked as deleted in the new tip version.
Step 3: Verify the Node is Restored
Call GET tip version nodes to retrieve the nodes in the new tip version.
Verify that the restored node is returned with isDeleted set to false.
Request
Response
The node is no longer marked as deleted in the latest tip version.
Congratulations! You have successfully restored a deleted node in a classifications tree.
Imported from the Autodesk Platform Services documentation: https://aps.autodesk.com/en/docs/acc/v1/tutorials/classifications/restore-node.