To delete a device from the inventory, you can use the DELETE
method with the devices endpoint. This will delete all the information related to that device from the database.
Note: This command only deletes the device's information. It will not change the device's status to decommissioned. To change the device's status, you should use a POST request to update the device's information.
API Request
Python Code
Request:
DELETE ot-base/api/v1/devices/deviceID
import requests
# Enter your hostname (for example: myserver.com or 127.0.0.1)
hostname = 'enterHostname'
# Enter a deviceID between the quotes.
deviceID = 'enterDeviceID'
# Set the base URL
url = 'https://'+hostname+'/ot-base.example.com/api/v1/devices/'+ deviceID
# Set the authentication credentials
auth = ('', '')
# Send the DELETE request
response = requests.delete(url, auth=auth)
# Check the response status code
if response.status_code == 204:
print('Device', deviceID, 'successfully deleted.')
else:
print('Error deleting device:', response.text)
Comments
0 comments
Please sign in to leave a comment.