Re: Bulk Export Activity API expected output

Anonymous
Not applicable

Bulk Export Activity API expected output

The question that I have is regarding the Get Export Activity File API functionality.

Marketo API -  Bulk Export Activity API

Resource -  Get Export Activity File  [GET /bulk/v1/activities/export/{exportId}/file.json]

The implementation notes says ;

Returns the file content of an export job. The export job must be in "Completed" state. Use Get Export Lead Job Status endpoint to retrieve status of export job.

I found a job which is in Completed state and passed it on to this API but it did not return me any results. Could you kindly let me know;

  1. What actually should be returned as the response?

  Should it; 

  • Return a text response?
  • Return a file?
  • Return a JSON response?

  1. Right now I’m receiving a blank response with the following response headers and that’s it. Why isn't this scenario returning me any results and what sort of an invocation should I be doing in order to get a proper response?

connection →keep-alive

content-disposition →attachment; filename=file

content-length →66

content-type →text/csv

date →Tue, 13 Mar 2018 00:42:37 GMT

server →nginx

Note: I’ve tried this out against the Marketo Sandbox environment where the REST API endpoint is https://743-YFC-765.mktorest.com/rest.

6 REPLIES 6
SanfordWhiteman
Level 10 - Community Moderator

Re: Bulk Export Activity API expected output

The file endpoint is your CSV file (as should be clear from the headers). At 66 bytes it's probably just headers at best, though. Did you choose a date range in the future or far past by accident?

Anonymous
Not applicable

Re: Bulk Export Activity API expected output

Hi Sanford,

Thanks a lot for the prompt response. So this is what I did.

1. Get Paging token

First I got a page token by calling the endpoint - /rest/v1/activities/pagingtoken.json

2. Get Lead Activities

Then I invoked the endpoint - /rest/v1/activities.json by passing the nextPageToken returned from the previous endpoint call along with the activityTypeIds.

From this list, I was able to capture the dates that the activities have been created.

3. Create Export Activity Job

Endpoint called - /bulk/v1/activities/export/create.json

Then I created a job for all the activityIds which I used to call the previous endpoint call along with the created date which I got by invoking the previous endpoint.

I'm using the exportId which was generated for the job that I just created.

4. Enqueue Export Activity Job

Endpoint called - /bulk/v1/activities/export/${exportId}/enqueue.json

5. Get Export Activity File

Endpoint called - /bulk/v1/activities/export/${exportId}/file.json

I waited until the job went from Created -> Enqueued -> Processing -> Completed

Then called the endpoint and it returns only the following headers. The Body size in bytes value shows the size as 213 and looks like it's sending a blank file with new lines and that's the reason for the output I see.

I tested this scenario with two different client tools and the results are the same. It's just returning a blank file with a bunch of new lines (\n).

****************************************************************************************************

Thread Name: [Direct Invocation of Marketo API Backend] - Bulk Activity APIs 1-1

Sample Start: 2018-03-14 13:07:14 AEDT

Load time: 123

Connect Time: 0

Latency: 123

Size in bytes: 401

Headers size in bytes: 188

Body size in bytes: 213

Sample Count: 1

Error Count: 0

Data type ("text"|"bin"|""): text

Response code: 200

Response message: OK

Response headers:

HTTP/1.1 200 OK

Server: nginx

Date: Wed, 14 Mar 2018 02:07:14 GMT

Content-Type: text/csv

Content-Length: 213

Connection: keep-alive

Content-Disposition: attachment; filename=file

HTTPSampleResult fields:

ContentType: text/csv

DataEncoding: null

****************************************************************************************************

It would be great if you can verify what's causing this and whether you too can see the same behavior from your end as well?

SanfordWhiteman
Level 10 - Community Moderator

Re: Bulk Export Activity API expected output

You're mixing together multiple APIs.

The Bulk Extract API uses the sequence Identity → Create → Enqueue → Status → Download. It doesn't use the paging token in the way you describe.

You would have to post the JSON payloads at each step to troubleshoot further (please use the Advanced Editor's JavaScript syntax highlighter when posting code to the Community).

Anonymous
Not applicable

Re: Bulk Export Activity API expected output

Sure. Will do. However, I don't see the Advance Editor. Any idea why? See below attachment.

editor.png

SanfordWhiteman
Level 10 - Community Moderator

Re: Bulk Export Activity API expected output

Click the name of the thread topic to focus it, then hit reply.

Anonymous
Not applicable

Re: Bulk Export Activity API expected output

While troubleshooting along the clues you gave me, I was able to find out the problem for this behavior.

Initially, when I was creating the export job, I used the payload which is specified in the API documentation at [1]. In that, the given example request value is something like what's shown below;

{

  "columnHeaderNames": {},

  "fields": [

    "createdAt"

  ],

  "filter": {

    "activityTypeIds": [

      1,

      12,

      13

    ],

    "createdAt": {

      "endAt": "2017-07-31T23:59:59-00:00",

      "startAt": "2017-07-01T23:59:59-00:00"

    }

  },

  "format": "CSV"

}

Then, while I was going through the rest of the documentation, I found out the following payload at [2];

{

   "format": "CSV",

   "filter": {

      "createdAt": {

         "startAt": "2017-07-01T23:59:59-00:00",

         "endAt": "2017-07-31T23:59:59-00:00"

      },

      "activityTypeIds": [

         1,

         12,

         13

      ]

   }

}

When I used the second payload to create the job, I was able to get the response as expected for the Get Bulk Activity File scenario. It returns the expected result.

Thanks a lot for looking into this and really sorry about the noise.

[1] - http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Bulk_E...

[2] - http://developers.marketo.com/rest-api/bulk-extract/bulk-activity-extract/