Deleting a file
Start the Python shell and configure its session.
The following variables should be available now:
>>> base_url # the base URL of the API 'https://eu2-cloud.acronis.com/api/notary/v2' >>> auth # the 'Authorization' header value with the access token {'Authorization': 'Bearer 8770b34b74f9e4d9424eff50c38182bb4ae7f5596582ae61900b1b6a23e3ec58'}
Define a variable named
file_id
, and then assign the ID of the required file to this variable:>>> file_id = 'cc3ecc8d-de0e-4809-8bc2-3a6368110824'
Fetch the file information, and then save the notarization certificate ID stored in the
certificate_id
key of the fetched object as described in “Fetching the information about a file”. You will always be able to fetch this certificate by sending the GET request to the/certificates/{certificate_id}
endpoint or to access the certificate web page at:https://eu2-cloud.acronis.com/notary/certificate/{certificate_id}
Delete the file by sending a DELETE request to the
/stored-files/{file_id}
endpoint:>>> response = requests.delete(f'{base_url}/stored-files/{file_id}', headers=auth)
Check the status code of the response:
>>> response.status_code 204
Status code 204 means that the notary service has deleted the file from the storage and decreased the usage of the Notary storage quota. If the file was signed or was being signed, its e-sign document and the PDF file of the certificate have been also deleted. If the status code is 404, there is no file with such an ID in the storage. You may have incorrectly specified the ID or the file has already been deleted.
A different status code means that an error has occurred. For the details, refer to “Status and error codes”.