Dropbox Settings

Post Reply
Jamesnic7
Newbie
Posts: 11
Joined: Sat Dec 31, 2016 3:21 pm

Dropbox Settings

Post by Jamesnic7 »

Hi
Has anyone managed to setup a link to dropbox to upload job files using the HTTP Configurator.
I have created an app on the account and obtained a token but I keep getting "401" Uthentification errors.
cstevens
Member
Posts: 103
Joined: Tue Feb 12, 2013 8:42 pm

Re: Dropbox Settings

Post by cstevens »

If you look at the documentation in the Scripting help for HTTP it shows how to do this in the scripting interface:

Code: Select all

function jobArrived( s : Switch, job : Job )
{
  var theHTTP = new HTTP( HTTP.SSL ); 

  theHTTP.authScheme = HTTP.OauthAuth;
  theHTTP.authorization = "authorization string";
  theHTTP.setAttachedFile( job.getPath() );
  theHTTP.url = "https://api-content.dropbox.com/1/files_put/auto/Test.pdf"; 

  theHTTP.post(); 

  job.log( 4, "Upload started", 100);
  while( !theHTTP.waitForFinished( 3 ) )
  {
  job.log( 5, "Uploading...", theHTTP.progress() );
  }
  job.log( 6, "Upload finished" ); 
  job.log( 1, "Server response: %1", theHTTP.getServerResponse().toString( "UTF-8" ) );
  if( theHTTP.finishedStatus == HTTP.Ok && theHTTP.statusCode == 200 )
  {
      job.log( 1, "Upload completed successfully" );
  }
  else
  {
      job.fail( "Upload failed with the status code %1", theHTTP.statusCode );
      return;
  }
  job.sendToSingle( job.getPath() );
}
I don't see why you couldn't do the same with the HTTP element if you set the following properties:
cstevens
Member
Posts: 103
Joined: Tue Feb 12, 2013 8:42 pm

Re: Dropbox Settings

Post by cstevens »

I'm not sure if the HTTP element uses SSL or not, that would be a possible hangup.
mgalvin
Newbie
Posts: 2
Joined: Mon Jun 23, 2014 7:50 am

Re: Dropbox Settings

Post by mgalvin »

Has anyone had success with getting dropbox API v2 to work. I have API v1 working but this is deprecated and will stop on the September 28th, 2017. This is the code that currently works.

Code: Select all

function jobArrived( s : Switch, job : Job )
{
	var theHTTP = new HTTP( HTTP.SSL ); 
	theHTTP.authScheme = HTTP.OauthAuth;
	theHTTP.authorization = "Bearer authorisation String";
	theHTTP.url = "https://content.dropboxapi.com/1/files/auto/xxxxx.pdf";
	theHTTP.localFilePath = job.createPathWithExtension( "pdf", false ); 

	theHTTP.get(); 

	job.log( 4, "Download started", 100 );
	while( !theHTTP.waitForFinished( 3 ) )
	{
      job.log( 5, "Downloading...", theHTTP.progress() );
	}
	job.log( 6, "Download finished" ); 

	if( theHTTP.finishedStatus == HTTP.Ok && theHTTP.statusCode == 200
          && File.exists( theHTTP.localFilePath ) )
	{
      job.log( 1, "Download completed successfully" );
      job.sendToSingle( theHTTP.localFilePath );
	}
	else
	{
      job.fail( "Download failed with the status code %1", theHTTP.statusCode );
	 job.sendToData(3,job.getPath() );
      return;
	}
   job.sendToNull( job.getPath() );
}
Post Reply