I’ve been working on a big project to launch Box (www.box.com) at my company. Box is a fantastic web based file sharing service. I won’t go into details here, but check them out if you need to share files securely with others. My next few blog posts will focus on some of the aspects of that project.
One of the requirements was to automatically load files to Box shared folders. These files needed to included data from our ERP. For example, one file needed to list inventory levels and needed to be updated on a frequent basis. I definitely didn’t want to do this manually, so I turned to some automation. Jitterbit (www.jitterbit.com) is a tool we use for all sorts for data integration, and it came through in this project as well.
The first step was to create an “application” in Box. There are detailed instructions here: http://developers.box.net/w/page/12923956/ApiOverview. Once you have your API key, you are ready for the next step of getting an authentication token as outlined at http://developers.box.net/w/page/12923915/ApiAuthentication. It is pretty easy to just use REST API calls right from a browser to get the token:
- Get a ticket by entering the following into your web browser (replace <apikey> with the one you obtained above: https://www.box.net/api/1.0/rest?action=get_ticket&api_key=<apikey>
- Use the ticket retrieved to authorize your application to your account: https://www.box.net/api/1.0/auth/<ticket>
- Finally retrieve the auth token: https://www.box.net/api/1.0/rest?action=get_auth_token&api_key=<apikey>ticket=<ticket>
Now that you have your auth token, you are ready to setup an upload process in Jitterbit. I’m assuming you already have some experience with Jitterbit and transformations. If not, Jitterbit has some great examples in their application help and online. You’ll need an http target setup with the following parameters:
- URL (replace <authtoken> with your actual auth token, leave [folderid] as is: https://upload.box.net/api/1.0/upload/<authtoken>/%5Bfolderid%5D
Next, create a script to set some variables. $folderid is the id of the folder you want to upload to. You can get this by browsing to the folder in Box and looking for the 9 digit number in the URL. The filename should be changed to what you want.
$folderid = ‘123456789’;
$jitterbit.target.http.form_data = true;
$jitterbit.target.http.form_data.filename = “File Name.csv”;
Put this all together into an operation and run it. It should look something like Script->Source->Transformation->Target in the graphical editor. When it runs, the transformation will be performed and the file added to the Box folder.