-1

I Am New TO dropbox api Today i tried to upload a file from https api but got error while uploading the file

Unknown API function: "files/upload

My code is

function main() local oHTTP,cJSON,url setmode(25,80)

ctoken      :=     "<REDACTED>"

* //  cJSON = {"path": "hb_cwd()+"report.txt","mode": "add","autorename": true,"mute": false,"strict_conflict": false"}



     url := "https://content.dropboxapi.com/2/files/upload \" + ctoken
     cJSON := '{"c:\tmp\pdf\CKF1907319.pdf","mode": "add","autorename": true,"mute": false,"strict_conflict": false,}'

? URL ? cjson wt = inkey(0)

oHTTP := CREATEOBJECT('Msxml2.ServerXMLHTTP.6.0')
oHTTP:OPEN("POST",  url , .F.)
oHTTP:setRequestHeader("Content-Type", "application/octet-stream")
oHTTP:SEND(cJSON)
    IF oHTTP:status != 200
    ? oHTTP:responseText
    hb_memowrit("response.txt",oHTTP:responseText)
    ? "Error"
ELSE
     ? oHTTP:responseText
     hb_memowrit("response.txt",oHTTP:responseText)
     ENDIF
     wt = inkey(0)
     return

Please help to solve this isssue

Thank You Vikram

3
  • What language is this? JSCript .NET? It's easier for people to help if they browse by the correct tags. Also, it looks like you added your token to your example. A token should be considered a secret and should not be shared with other people.
    – Simon S.
    Commented Apr 16, 2020 at 13:51
  • @Vikram, if it was a security token you should disable it ASAP. It remains available in the history of this question. People will be able to abuse it
    – Evert
    Commented Apr 16, 2020 at 13:52
  • @Vikram I redacted it from your post, but you should revoke that access token for your security.
    – Greg
    Commented Apr 16, 2020 at 13:54

1 Answer 1

0

[ Cross-linking for reference: https://www.dropboxforum.com/t5/Dropbox-API-Support-Feedback/Error-In-Uploading-a-file/td-p/410748 ]

The URL for the Dropbox API upload endpoint is just "https://content.dropboxapi.com/2/files/upload". You appear to be adding your access token to the end of the URL, based on this line of code:

url := "https://content.dropboxapi.com/2/files/upload \" + ctoken

The access token should instead go in the "Authorization" header as a "Bearer" token, as shown in the /2/files/upload documentation here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.