Delete a Node from a Tree
This tutorial demonstrates how to delete a node from a classifications tree. The steps include retrieving the current tip-version nodes, reimporting the tree structure without the node you want to remove, and verifying that the node is 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
Call GET tip version nodes to retrieve the current nodes in the tree. Use the response to identify the node you want to remove.
Request
Response
In this example, assume you want to delete 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 remove the node from the hierarchy.
Step 2: Reimport the Tree Without the Deleted Node
To delete the node, use the tree ID (0295f158-6f95-7fb0-b008-4cde506166ee) to call POST trees:reimport.
Provide the complete tree structure in importData, excluding the node you want to remove from the hierarchy. In this example, Room 102 is omitted from importData.
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 without the ROOM-102 node. In the next step, verify that the node is marked as deleted in the new tip version.
Step 3: Verify the Node is Deleted
Call GET tip version nodes with includeDeleted=true to retrieve the nodes in the new tip version, including deleted nodes.
Verify that the node you omitted from importData is returned with isDeleted set to true.
Request
Response
The node is now marked as deleted in the latest tip version.
Congratulations! You have successfully deleted a node from a classifications tree.
To restore a node that has been marked as deleted, see the Restore a Deleted Node in a Tree tutorial.
Imported from the Autodesk Platform Services documentation: https://aps.autodesk.com/en/docs/acc/v1/tutorials/classifications/delete-node.