cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know more about how you can find anything and protect everything? Check it out here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Converting from V1 to V2

Converting from V1 to V2

ERS R.
Explorer | Level 3

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 2

Steve M.
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.
Explorer | 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.
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    ERS R. Explorer | Level 3
  • User avatar
    Steve M. Dropbox Staff
What do Dropbox user levels mean?