Use cURL to Import Leads via the REST API

December 16, 2014 | by

Do you want to import leads from a CSV file through the REST API, but noticed this is challenging to do using the Postman Chrome extension. In this post, we’ll walk through how to do this with cURL.

Step One
Download and install cURL, a command line tool we’ll use to push data to Marketo’s REST API.

Step Two
Open the command line, and then navigate to the location where the CSV file is located. Here is an example file with the expected format. The column headers in the CSV file must match the API field names, not the Marketo field names.

Step Three
You will need an access token. Login to Marketo, go to Admin, and then LaunchPoint. Find your REST API user and click “View Details”. Click the “Get Token” button. If you have not authenticated with the Marketo REST API before, please follow this guide.

Step Four
You will also need your REST endpoint that is specific to your Marketo instance. Login to Marketo, and go to Admin, and then Web Services. In the section marked “REST API” you’ll find the Endpoint URL.

Step Five
On the command line, follow this format for the cURL call. Replace <accesstoken> with your access token from Step Three and replace <REST API Endpoint URL> with your REST API Endpoint URL from Step Four.

More info is available here. The “/bulk” here will replace the “/rest” at the end of the Endpoint URL. If you have the endpoint set for /rest/bulk it will return an error.