Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hello,
follow my code below:
***
Taux_API_Arg = '{'
Taux_API_Arg += '"path":"/codechain/extrato.pdf",'
Taux_API_Arg += '"mode":"overwrite",'
Taux_API_Arg += '"autorename":true,'
Taux_API_Arg += '"mute":false'
Taux_API_Arg += '}'
cBuff := FileStr("C:\Onedrive\fontes\ManagerDropbox\extrato.pdf")
cEncBuff := hb_Base64Encode( cBuff, Len( cBuff ) )
oHttp := CreateObject("MSXML2.ServerXMLHTTP.6.0")
oHttp:Open("POST", "https://content.dropboxapi.com/2/files/upload", .f.)
oHttp:setRequestHeader("Authorization","Bearer " + alltrim(Taux_Token) )
oHttp:setRequestHeader("Content-Type", "application/octet-stream")
oHttp:setRequestHeader("Dropbox-API-Arg", Taux_API_Arg )
oHttp:Send(cEncBuff)
***
The file is transferred to the Dropbox repository, but with a larger size, therefore corrupted !!
Original size: 58.28 Kb
Size after download: 77.44 Kb
PS: Transferring by POSTMAN, works correctly.
Grateful
The /2/files/upload endpoint is a "content-upload" style endpoint, meaning that it expects the raw file data to be uploaded as 'application/octet-stream' in the request body. That being the case, you should send only the file data in the request body, without any additional encoding. I see in your code, for instance, that you appear to be applying a layer of base64 encoding, via the hb_Base64Encode call. You should remove that, and make sure you're only sending the expected bytes for the file.
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!