We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
ERS R.
9 years agoExplorer | Level 3
Converting from V1 to V2
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?
2 Replies
- Steve M.9 years ago
Dropbox Staff
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
- ERS R.9 years agoExplorer | Level 3
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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,035 PostsLatest Activity: 13 minutes ago
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If you need more help you can view your support options (expected response time for an email or 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!