1. Giuseppe moglia
  2. PowerBuilder
  3. Thursday, 14 March 2019 14:55 PM UTC

Hi Guys 

anyone has already experienced a connection to Dropbox api and a download of a file?

 

Thanks

Kevin Ridley Accepted Answer Pending Moderation
  1. Wednesday, 24 April 2019 11:52 AM UTC
  2. PowerBuilder
  3. # 1

The dropBox webcast is scheduled for 5/22 and is currently listed on the website.  There is a link to signup following.  Hope to see everyone there.

 

https://www.appeon.com/company/events/using-dropbox-rest-api-powerbuilder.html

Comment
  1. Giuseppe moglia
  2. Wednesday, 24 April 2019 14:46 PM UTC
Thank you Kevin, I will attend

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!
  1. Helpful
  1. Kevin Ridley
  2. Wednesday, 24 April 2019 17:48 PM UTC
That's great! Always nice to hear that someone has success after helping out. That's what we're here for. I'll see you online on the 22nd.
  1. Helpful
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Friday, 12 April 2019 16:32 PM UTC
  2. PowerBuilder
  3. # 2

Giuseppe and Gimmy,
I'm putting together a presentation on this and will be doing an official Appeon webcast, so keep an eye out, it should be soon. It will cover DropBox API - listing files/folders as well as uploading and downloading all file types to/from any shared DropBox folder. It will cover creating a service account for dropbox, generating an OAuth access token, and using that token for DropBox REST API calls. We are currently deciding on a title and date for the webcast, so stay tuned!

Comment
  1. Kevin Ridley
  2. Wednesday, 17 April 2019 11:53 AM UTC
It should be announced in the next day or 2, but the DropBox webcast will be May 22nd. I'll post a link here once it's officially on the website schedule.
  1. Helpful
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Monday, 1 April 2019 19:29 PM UTC
  2. PowerBuilder
  3. # 3

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

Comment
There are no comments made yet.
Giuseppe moglia Accepted Answer Pending Moderation
  1. Friday, 15 March 2019 14:38 PM UTC
  2. PowerBuilder
  3. # 4

thank you Kevin

no issue about connecting, the issue is about downloading...

Comment
  1. Kevin Ridley
  2. Friday, 15 March 2019 18:31 PM UTC
So you are using OAuthClient and you are able to get the access token from the site? If so, so the 2nd and third links below for getting the list of files and file requests.
  1. Helpful
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Thursday, 14 March 2019 18:06 PM UTC
  2. PowerBuilder
  3. # 5

I haven't tried it yet but did some quick research on it.  Looks like as with most REST services, it's going to be a 2 part process.  First you will need to connect/authenticate using OAuth to get an access token, then you will use that access token for all REST calls.  Check out this link for how to get started.  I'd recommend using the App Key and Secret to do this.  The link tells you how to generate your app key and secret code and generate an access token.  Then you will use that access token to download the file (and anything else you might want to do).  You generate the access token once and use it for all API calls.

 

https://www.dropbox.com/developers/support

 

Once you generate the app key, secret and access token, use the OAuthClient object to make all API calls with the access token.  Below are 2 links for retrieving a list of files/folders and for downloading a file by name.

 

Note: updated on 4/15/19.  I replaced some text above regarding the access token.  Normally using OAuth, you have to request an access token using your client id and client secret in your first call, then use the access token for your session.  DropBox does it a little different.  You generate the access token once when you setup your service account, so you don't have to make a separate call to get it.

 

https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder

https://www.dropbox.com/developers/documentation/http/documentation#files-download

 

They return JSON, so you can probably setup a nice DW showing the file list, then cal the get when they select one.  Looks like fun!

 

Cheers,

Kevin

Comment
  1. Kevin Ridley
  2. Friday, 12 April 2019 16:26 PM UTC
I'm going to post a reply above, but I will post here too. I'm currently setting up a webcast for DropBox that will cover listing files and folders as well as uploading and downloading files, so stay tuned. I'll post here once we have a date and the code will be made available on CodeXchange.
  1. Helpful
  1. ATK Gimmy Susan
  2. Friday, 12 April 2019 18:59 PM UTC
thank you Kevin
  1. Helpful
  1. Giuseppe moglia
  2. Monday, 15 April 2019 07:52 AM UTC
Thank you Kevin!
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.