Update and Delete a File Request
Learn how to update and delete a file request.
We'll cover the following...
In this lesson, we’ll encounter two very important operations within the file_requests namespace, which are the following:
updatedelete_all_closed
They both require us to enable the file_requests.write permission.
Update a file request
We use the /file_requests/update endpoint to update the properties of a file request. It uses the same parameters as the create endpoint. Let’s update the title of the file request and close it.
import requestsimport jsonurl = "https://api.dropboxapi.com/2/file_requests/update"headers = {"Authorization": "Bearer {{TOKEN}}","Content-Type": "application/json"}data = {"id": "{{FILE_ID}}","title": "Let's modify demoFileByAPI","open": False}r = requests.request("POST",url, headers=headers, data=json.dumps(data))print(json.dumps(r.json(), indent=4))
In the code above, we see the following:
- Lines 11–15: We assign a file request ID to the
idparameter, a new title to thetitleparameter, and the valueFALSEto theopenparameter. - Line 17: We define the HTTP request.
- Line 18: We print the response.
Response fields
After we’ve successfully executed the code above, the properties of the file request will be returned with updated values. Now, we’ll visit the Dropbox dashboard and select the “File requests” option, followed by the “Closed” tab. We’ll see our closed file request here.
The properties that weren’t mentioned in our call will remain unchanged—for example, the destination and description properties.
Delete all closed file requests
The /file_requests/delete_all_closed endpoint allows us to delete all file requests that have been closed. It requires us to enable the file_requests.write permission and doesn’t take any parameters.
import requestsimport jsonurl = "https://api.dropboxapi.com/2/file_requests/delete_all_closed"headers = {"Authorization": "Bearer {{TOKEN}}","Content-Type": "application/json"}data = Noner = requests.request("POST",url, headers=headers, data=json.dumps(data))print(json.dumps(r.json(), indent=4))
Response fields
The code above will delete the file that we closed in the previous section. The “Closed” tab in the “File requests” section is now empty. Let’s see some of the important response fields in the table below.
Field | Description |
| This is the unique ID of the deleted file request. |
| This is the link to the file request that will now give a 404 error. |
| This is the title of the file request. |
| This is the path to the Dropbox folder where this file request was deleted. |
| The description of the file request |