Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Working in VBA.
The following V1 code works:
Sub DeleteFile(filename As String)
Dim req As MSXML2.ServerXMLHTTP60
Dim Result As String
Dim Pos1 As Integer
Dim Pos2 As Integer
Set req = New MSXML2.ServerXMLHTTP60
req.Open "POST", "https://api.dropboxapi.com/1/fileops/delete?path=" & "/" & filename & "&root=auto", False
req.setRequestHeader "Authorization", "Bearer ##########"
req.send
If req.Status = 200 Then
Debug.Print req.responseText
Else
MsgBox req.Status & ": " & req.statusText
Debug.Print req.responseText
End If
The following conversion to V2 does not work:
Sub DeleteFile2(filename As String)
Dim req As MSXML2.ServerXMLHTTP60
Dim Result As String
Dim Pos1 As Integer
Dim Pos2 As Integer
Set req = New MSXML2.ServerXMLHTTP60
Dim arg As String
arg = "{""path"": ""/" & filename & """}"
req.Open "POST", "https://api.dropboxapi.com/2/files/delete", False
req.setRequestHeader "Authorization", "Bearer ##########"
req.send (arg)
If req.Status = 200 Then
Debug.Print req.responseText
Else
MsgBox req.Status & ": " & req.statusText
Debug.Print req.responseText
End If
End Sub
The error I get is:
"Error in call to API function "files/delete": This function requires its argument in the HTTP request body, but your request body is empty."
Similar problem implementing other file functions.
Any ideas?
I'm not sure why you're getting that error, since you appear to be sending a request body.
But note that you're missing this:
req.setRequestHeader "Content-Type", "application/json"
and this line:
req.send (arg)
should really be this (but I don't think the extra parentheses are causing issues):
req.send arg
req.send (arg) was just because it wasn't working...originally I had it w/o parenthesis.
However, adding req.setRequestHeader "Content-Type", "application/json" fixed the issue. Thank you very much.
Hi there!
If you need more help you can view your support options (expected response time for a ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!