This article describes how to connect and upload files to Box.com using HTTP Client Connector with OAuth2.0 authentication.
The approach will use the HTTP Client connector to interact with the Box.com REST API and upload a sample file to Box.com. While doing so we will configure the necessary OAuth 2.0 settings in the same fashion with How to Connect to Box.com with OAuth 2.0 article.
Create HTTP Connection in boomi for box.com upload operation.
Define the file meta data and file content by using message shape.
Format the HTTP request in accordance with box.com API documentation
Execute the process and validate the result
The following steps detail how to deploy a process using the AtomSphere HTTP Client Connector when connecting to Box.com’s REST API:
1) Follow How to Connect to Box.com with OAuth 2.0 in order to create Box.com HTTP connection. Please be aware that upload file for box.com has a different base URL which is https://upload.box.com/api/2.0 .
2) Create a sample process that starts with No Data option then add a message shape. Message shape can be utilized to create and define the file description. For example:
Content-Disposition: form-data; name="metadata"
Content-Disposition: form-data; name="file"; filename="helloWorld.txt"
Here the file name and parent folder id needs to be passed as a JSON object in metadata section as per Box.com API Upload operation:
parent id=0 means that the file will be uploaded to the root folder. You should use the folder id as the parent id value if you're trying to upload the document to a specific folder. Folder id can be found in the box.com URL. For example if you open a folder in box.com the URL will look like below:
Where "12345678901" is the folder/parent ID.
3) Once the message shape is configured, add a Data Process shape in order to add a carriage return. This step might change or might not be needed depending on your file:
Text to Find: [\n]
Replace With: [\r][\n]
4) Configure HTTP Client Connector Operation with below parameters:
Content Type: multipart/form-data; boundary="simpleboundary"
Resource Path: files/content
A successful attempt would return application status code 201. Because Return HTTP Errors box is checked in the Operation, add a decision shape in order to check the returned Application Status Code document property. Here is how the Decision shape should be configured:
First Value: Document Property - Base - Application Status Code
Comparison: Equal To
Second Value: 201
Connect these shapes to each other like shown below:
Execute your process.
4) A successful post would result in a JSON response document in below format. The response should contain the new file's id:
The complete JSON response can be found here.
Login to box.com and verify that your file has been uploaded.