10-16-2016, 01:20 AM
Sorry to ask this, but:
1)
Could you add: List folder: https://www.dropbox.com/developers/docu ... ist_folder
I tried but I am constantly getting JSON errors.
r.Open => https://api.dropboxapi.com/2/files/list_folder
=================================================================
2)
And how can I make the beneath code for downloading work properly.
It works, but the contents of the file is put in "rt" at the bottom of below code.
I want to acutually save the fale to local disk. (Do I need to use the __stream class?)
Macro dropbox_download
If needed (it is almost same as upload):
r.Open => https://content.dropboxapi.com/2/files/download
1)
Could you add: List folder: https://www.dropbox.com/developers/docu ... ist_folder
I tried but I am constantly getting JSON errors.
r.Open => https://api.dropboxapi.com/2/files/list_folder
curl -X POST https://api.dropboxapi.com/2/files/list_folder \
--header "Authorization: Bearer %%%%TOKEN%%%%" \
--header "Content-Type: application/json" \
--data "{\"path\": \"/Homework/math\",\"recursive\": false,\"include_media_info\": false,\"include_deleted\": false,\"include_has_explicit_shared_members\": false}"
"path": "/Homework/math",
"recursive": false,
"include_media_info": false,
"include_deleted": false,
"include_has_explicit_shared_members": false
}
=================================================================
2)
And how can I make the beneath code for downloading work properly.
It works, but the contents of the file is put in "rt" at the bottom of below code.
I want to acutually save the fale to local disk. (Do I need to use the __stream class?)
Macro dropbox_download
str to_download="/Homework/math/test3.csv"
;;________________________________________________________
;;|
;;| Authorizes your Dropbox application (actually the caller macro) to use Dropbox API with user's Dropbox account.
;;|
;;| appKey - from https://www.dropbox.com/developers/apps -> your app -> App key.
;;| appSecret - from https://www.dropbox.com/developers/apps -> your app -> App secret.
;;|
;;[PKEK8]_________________________________________________
str _token=""
str appKey=""
str appSecret=""
;authToken -> bearer token
WinHttp.WinHttpRequest r._create
r.Open("POST" F"https://api.dropboxapi.com/1/oauth2/token?code={_token}&grant_type=authorization_code&client_id={appKey}&client_secret={appSecret}")
r.Send()
;;________________________________________________________
;;|
;;| Start the DOWNLOAD
;;|
;;[XJPS4]_________________________________________________
r.Open("POST" "https://content.dropboxapi.com/2/files/download")
r.SetRequestHeader("Authorization" F"Bearer {_token}")
str arg=
F
;{{
;"path": "{to_download}"
;}
arg.findreplace("[]" " ")
r.SetRequestHeader("Dropbox-API-Arg" arg)
r.Send()
str rt=r.ResponseText
if(r.Status!=200) end _s.from(r.StatusText ". " rt)
out rt ;; OUTPUTS CONTENTS OF FILE!
If needed (it is almost same as upload):
r.Open => https://content.dropboxapi.com/2/files/download
curl -X POST https://content.dropboxapi.com/2/files/download \
--header "Authorization: Bearer %%%%TOKEN%%%%" \
--header "Dropbox-API-Arg: {\"path\": \"/Homework/math/Prime_Numbers.txt\"}"