Connecting to Marketo with the REST Snap Pack
While SnapLogic’s REST OAuth account supports only OAuth 2.0, it does not work with Marketo’s OAuth implementation. To work with Marketo, you must authenticate manually using the REST Get Snap. In this pipeline, we pass the credentials in as pipeline parameters. Note: This method does expose your credentials in the pipeline. Authorization To simplify the process, define the following pipeline parameters url: the REST API URL for your Marketo instance, like: https://xxx-xxx-xxx.mktorest.com clientID: The clientID for API access. clientKey: The client secret for API access. Add a REST Get Snap (labeled Marketo Login here) and configure as follows: For Service URL, toggle on the Expression button ( = ) and set the field to: _url + '/identity/oauth/token?grant_type=client_credentials&client_id=' + _clientID + '&client_secret=' +_clientKey Remove the input view. Validate the Snap and it will a return a response that contains an access_token and scope. In this example, we follow the REST Get with a Mapper Snap to map the token outside of the array. Using the Access Token In subsequent Snaps, we pass this token as a header, rather than a query parameter because it simplifies paged operations such as Get Lead Changes. Here’s an example of a simple call which does this. For Service URL, toggle on the Expression button ( = ) and set the field to: _url + '/rest/v1/activities/types.json' Under HTTP Header, set Key to Authorization and Value with the Expression button ( = ) toggled on to ‘Bearer ‘ + $accessToken Paged Operations When you get to more complex operations, such as getting lead changes, you need to make two API calls: the first creates a paging token, and the second uses the paging token typically with the paging mechanism enabled in our REST GET Snap. Get Paging Token In this REST Get Snap (renamed Get Paging Token for clarity) is where you specify the query parameters. For instance, if you want to get lead changes since a particular date, you’d pass that in via “sinceDateTime”. The example provided uses a literal string, but could be a pipeline parameter or ideally one of a Date objects formatted to match what Marketo expects. _url + '/rest/v1/activities/pagingtoken.json' Configure Paging Mechanism When calling Get Leads (via a REST GET Snap), a few things to bear in mind: You need to pass “nextPageToken” as a query parameter, along with the fields you want back. Ideally, the list of fields should be in a pipeline parameter because they appear twice in this configuration. The leads will be returned in $entity.result, which is an array. This field will not exist if there are no results, so you need to enable “Null safe” on a Splitter Snap after this REST Get. Paging expressions for the REST Get Snap are: Has next: $entity.moreResult == true Next URL: '%s/rest/v1/activities/leadchanges.json?nextPageToken=%s&fields=firstName,lastName'.sprintf( _url, $entity.nextPageToken ) API Throttling Marketo throttles API calls. Their documentation says “100 API calls in a 20 second window”. Since our REST Snap paging now includes an option to wait for X seconds or milliseconds between requests, use it whenever you are retrieving paginated results. Downloads Marketo REST.slp (14.7 KB)10KViews3likes11CommentsSnapLogic Public APIs for Pipeline Runtime Execution Info
Created by @cstewart This pipeline uses the SnapLogic Public APIs to read the summary of executions, then does two things with them; first writes the line detail retrieved into a file, and concurrently, also writes a summary into a file, so you can see what the output contains. This pipeline utilizes the following techniques: Using the iteration feature of the REST Get Snap so that the multiple iterative requests required to retrieve the detail from the SnapLogic Public APIs are consumed. Dynamically configuring the URLs used with the expression language ternary operator Using an expression to get the org name (for use in the URLs) Putting multiple different format data into a single output stream, with an implication of order Configuration The REST Get Snap will need a REST Basic Auth account with credentials valid to make the request to the platform, and the result will only include the results for those executions which those credentials have authority to see. Sources: SnapLogic API Targets: CSV and JSON Files Snaps used: REST Get, JSON Splitter, Copy, Aggregate, Mapper, Union, JSON Formatter, CSV Formatter, File Writer Downloads GetRuntimeInfo.slp (19.8 KB)3.3KViews1like0CommentsRecord Box files to Google Sheets
Created by @skatpally A file is uploaded to Box, SnapLogic stores the metadata of the file into Google Sheets as a new row Configuration Create App to get the access_token. You can also do OAuth2.0 Authentication Sources: Box Targets: Google Sheets Snaps used: REST Get, CSV Parser, WorkSheet Writer Downloads Record_Box_files_to_Google_Sheets.slp (6.0 KB)3.1KViews0likes0CommentsCollecting Error Data
Submitted by @stodoroska from Interworks The pipeline Error.Routine is collecting the error data and depending on the Error.Log parameters, these errors are logged into SQL Server database table and/or JSON file is created at some FTP location. Error.Routine Pipeline Error.Log Pipeline Configuration Parameters are configured for the parent and child pipelines. If the parameter used in the Filter Snap is set to logEnabled==‘true’, we are logging the error data, but if the parameter is logEnabled==‘false’, we are not processing further error data. Sources: Error data that is coming from Snap error view Targets: SQL Server table and/or a JSON file in File share system; email Snaps used: REST Get, Filter, Mapper, Pipeline execute, Router, SQL Server execute, JSON Formatter, File writer, Union, E-mail sender Downloads Error.Routine.slp (7.3 KB) Error.Log.slp (14.9 KB)3.2KViews1like0CommentsExport Accounts from Adaptive Insights
Contributed by @dshen This pipeline demonstrates how to connect to Adaptive Insights and export accounts using Rest API. Configuration To connect to Adaptive Insights, the user needs to provide the login username and password along with the calling method (e.g. exportAccounts) in the first Snap in order to construct the proper XML payload for the REST Post. Source: Adaptive Insights account Target: no target defined Snaps used: Mapper, Copy, XML Formatter, File Writer, Binary to Document, REST Post Downloads Adaptive Insights- Export Account Sample.slp (9.9 KB)2.9KViews0likes0CommentsRead candidates from Taleo using Rest API
Contributed by @dshen This pipeline demonstrates how to connect to the Taleo using Rest API and fetch candidate data. Configuration In order to connect to Taleo, the user needs to provide the following information in the REST Post Snap (titled Get Taleo authToken): Service URL to the Taleo instance Taleo orgCode of your organization Taleo username and password Source: Taleo Candidate Target: no target defined Snaps used: Rest Post, Rest Get, JSON Splitter Downloads Taleo Get Candidates.slp (5.8 KB)3.5KViews0likes0CommentsDropbox Samples via REST API
Contributed by @dshen This pattern contains 3 separate segments that demonstrate how to use the REST API to: list folder contents download a file from Dropbox upload a file to Dropbox Source: Dropbox Files Target: Dropbox Files Snaps used: JSON Generator, REST Post, JSON Splitter, Mapper, Document to Binary, CSV Parser Configuration Supply a Dropbox Bearer Token in the pipeline parameters. To list the contents of a folder, supply the Dropbox file path and other parameters in the JSON Generator so it can be passed to Dropbox as the request payload. For uploading a file to Dropbox, this pipeline assumes the file was uploaded to SnapLogic. Reference Dropbox API v2 for HTTP Developers Downloads Dropbox Samples.slp (14.4 KB)4.3KViews0likes0Comments