cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

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

SGArchitect
New Contributor II

Hi-

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.

image

Thanks
Suman

4 REPLIES 4

alchemiz
Contributor III

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

image

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

image

Single request

image
image

Hope this helps ๐Ÿ˜€

Thanks,
EmEm

SGArchitect
New Contributor II

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

image

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

image

SGArchitect
New Contributor II

@alchemiz Thank you very much. That worked.