How to download a csv file that is returned by Marketo REST API call


SnapLogic community has been of immense help for our organization.
As part of our initiative, we are required to make a Marketo REST API call and ingest the data into target system.

Marketo documentation: Lead Database - Marketo Developers

Marketo REST API ( [/bulk/v1/leads/export/{exportId}/file.json) returns a csv file. We are using the snap “REST Get” to make the Marketo REST API call. However, we are trying to figure out the best way to download the csv file that is returned by the REST API. Please note that the content returned by the REST API will be around 300 MB.

Appreciate any help on this.


Hi Suman,

Good day, you can use the HTTP Request Header “Range” by calling first the Marketo API Get Export Lead Job Status to get the file size and if requested export file is ready for download “Complete” state

Base from the file size you can then use Range as part of the GET request header in a multipart request or single request

Multipart request

Single request

Hope this helps :smiley:


Hi @alchemiz ,

Thank you very much for the response. I still couldn’t understand how I could download the CSV file. Could you please let me know the snap that I could use to download the CSV file once I make the REST API call “/bulk/v1/leads/export/{exportID}/file.json”?
“file.json” REST API call returns a CSV file as per Marketo documentation.

In the REST GET snap, set the response entity type to BINARY


This will output the entity as byte array, before you can write/download the file you need to map the $entity to $content… I use a mapper where output is set to binary the connected to a file writer snap


1 Like

@alchemiz Thank you very much. That worked.