The Smartsheet Apex Toolkit provides an Apex class library that interacts with the Smartsheet API, including an Apex object model and convenience methods for calling the API.
The Smartsheet API provides a REST interface to Smartsheet features and data. The API enables Smartsheet customers to programmatically access and manage their data, and empowers application developers to build solutions on top of Smartsheet.
For more information about the Smartsheet API, please visit http://www.smartsheet.com/developers for full API Documentation and sample applications.
####Revision History 1.0 - November 12, 2013 - Basic authentication and sheet actions coverage.
You can create a Sheet with a couple of columns as follows:
Smartsheet.Sheet sheet = new Smartsheet.Sheet();
sheet.name = 'My Sheet Name';
List<Smartsheet.Column> columns = new List<Smartsheet.Column>();
Integer numberOfColumns = 2;
for (Integer i = 0; i < numberOfColumns; i++) {
Smartsheet.Column column = new Smartsheet.Column();
if (i == 0) {
column.primary = true;
}
column.type = 'TEXT_NUMBER';
column.title = 'Column ' + i;
columns.add(column);
}
sheet.columns = columns;
####Authentication
- getAccessToken()
- refreshAccessToken()
- saveAccessToken()
- getRequestAuthCodeUrl()
####Sheet Actions
- getSheet()
- getSheets()
- createSheet()
- insertRows()
To enable your Salesforce application access to the Smartsheet API you'll need to create register a third-party app with Smartsheet or generate an API Access token in Smartsheet.
See the Smartsheet API documentation section on creating third-party applications.
See the Smartsheet API documentation section on how to generate a Smartsheet Access Token.
To start using the Smartsheet Apex Toolkit in your Salesforce Org install the unmanaged package of the library with the following URL:
https://login.salesforce.com/packaging/installPackage.apexp?p0=04ti00000004HZH
Click Continue -> Next -> Next -> Install
Create a List custom setting for organizational defaults in the Setup->Develop->Custom Settings->Smartsheet Config->Manage. On the Smartsheet Config Custom Setting page click the New button, and use the configuration values below:
- Name = a descriptive name
- API_Base_URL = https://api.smartsheet.com
- API_Version = 1.1
- Authorize_URL = https://www.smartsheet.com/b/authorize
- Scope = READ_SHEETS,WRITE_SHEETS,CREATE_SHEETS
- Redirect_URL = your-redirect-url
- Client_Id = your-smartsheet-client-id
- Client_Secret = your-smartsheet-secret
Interacting with the Smartsheet API requires a new remote site setting.
- Add a remote site for Smartsheet API site in the
Administration Setup
->Security Controls
->Remote Site Setting
->New Remote Site
. - Create new remote site and set
https://api.smartsheet.com
in the Remote Site URL.
##Force.com IDE Setup The cleanest way to include the toolkit in a Force.com IDE project is to have the IDE download the package when creating a new project.
The Force.com IDE can be found here:
http://wiki.developerforce.com/page/Force.com_IDE
To download the toolkit into a new project open the IDE and go to File
-> New…
-> Force.com project
.
Connect the project to your Salesforce account with your Salesforce username, password and Salesforce security token. Then, click Next.
In the Choose Initial Project Contents window there will be an option to Choose metadata components to download. Under that option select Contents of Package, and then choose Smartsheet Apex Toolkit from the dropdown.
The package contents will then be loaded into Force.com IDE project.
Included in the Toolkit is a VisualForce page, SmartsheetDemoPage, which implements a simple Smartsheet API demo. To use it and test the toolkit, go to https://<your-salesforce-server>/apex/SmartsheetDemoPage
:
- First, select one of the two available authorization types in the Authorization Type dropdown.
- When
User Generated Token
is selected, please type the user-generated-token in toGenerated Token
input field. Then clickLogin to Smartsheet
button. - When OAuth 2.0 is selected, then just click the
Login to Smartsheet
button and follow the OAuth 2 flow. - Once you have been authorized, you will see your your access token displayed in the Access Token field, and a dropdown with sample API methods you can try.
If you have any questions or suggestions about this document, the toolkit, or about the Smartsheet API in general please contact us at [email protected]. Development questions can also be posted to Stackoverflow with the tag smartsheet-api.
##Contributions We encourage community development on this library, and welcome any high quality contributions. Please submit a pull request if you develop enhancements or new methods for additional API coverage.
The Smartsheet Platform team