Giuseppe,
I spent some time on this over the weekend and got it working. Below is some code to download a file from a shared folder on DropBox. I set up the account as a service account and generated the Access Token on the DropBox site to use for all OAuth REST API requests. The result is a blob in the response body that you can write to a file or db or whatever you want to do with it. This code assumes you know the folder name and file name. I've requested to do a webcast to show how to get a list of files/folders, download a selected file, and upload as well, using OAuth2/REST. Keep an eye out for it if I get approval.
Cheers,
Kevin
Integer li_rc
OAuthClient lo_client
OauthRequest loa_request
ResourceResponse lrr_response
String ls_json, ls_file
Blob lblb_data
CONSTANT String DROPBOX_FOLDER = "/appeondemo"
Long ll_root, ll_item
ls_file = "mypdf.pdf"
ls_json = '{"path":"' + DROPBOX_FOLDER + '/' + ls_file + '"}'
try
lo_client = CREATE OAuthClient
loa_request.Method = "POST"
loa_request.setheader ( "User-Agent", "AppeonDemo" )
loa_request.setheader( "Content-Type","application/octet-stream")
loa_request.setheader( "Dropbox-API-Arg", ls_json)
loa_request.SetAccessToken( "Your Generated Token" )
loa_request.Url = "https://content.dropboxapi.com/2/files/download"
li_rc = lo_Client.RequestResource( loa_request, lrr_response )
If li_rc = 1 Then
lrr_response.GetBody(lblb_data)
//do something with the blob
Else
li_rc = -1
MessageBox("Error", lrr_response.getstatustext())
End If
return li_rc
catch(runtimeerror re)
MessageBox("RunTimeError", re.getmessage())
return -1
finally
IF IsValid(lo_client) THEN
DESTROY lo_client
END IF
end try
In the meantime, with your help we were able to create 2 exe uploading and downloading other powerbuilder compiled exe and pbd from dropbox
Thanks again!