Retrieving path_collection for File in Event Source with GET Enterprise Events API

Hi everyone,

I’m currently using the GET Enterprise Events API to retrieve a list of events with the event_type set to UPLOAD. The API returns Event Source as a File Type. However, I would like to get the path_collection of the file directly in the Event Source for easier processing and tracking.

Here’s an example of the API request I’m using:

GET https://api.box.com/2.0/events?stream_type=admin_logs_streaming&event_type=UPLOAD
Authorization: Bearer [ACCESS_TOKEN]

And here is an example of the JSON response I receive:

{
  entries: [
    {
      source: {
        item_type: 'file',
        item_id: 'file_xxx',
        item_name: 'xxx.docx',
        parent: {
          type: 'folder',
          name: 'Sub 5 - Folder',
          id: 'folder_xx',
        },
        owned_by: {
          type: 'user',
          id: 'user_xxx',
          name: 'Quang Mai',
          login: 'quang.mai@example.com',
        },
      },
      created_by: {
        type: 'user',
        id: 'user_xxx',
        name: 'Quang Mai',
        login: 'quang.mai@example.com',
      },
      action_by: null,
      created_at: '2024-07-01T21:19:36-07:00',
      event_id: 'xxxx',
      event_type: 'UPLOAD',
      ip_address: '',
      type: 'event',
      session_id: null,
      additional_details: {
        size: 0,
        version_id: '',
      },
    }
  ],
  chunk_size: 1,
  next_stream_position: 564669847452598,
}

As you can see, in the source section, I only get the basic information about the file. I would like to have the path_collection attribute to know the file path within the Box folder structure.

One way is to use the Get File Info API to retrieve it accurately. However, if the event list is large, it will take a lot of time and a large number of requests. This is really not ideal.

Is there any way to retrieve the path_collection of the file directly in the response from this API? Or is there another API that can help me get this information efficiently?

Thank you for your time and assistance!

Best regards,
Quang Mai

1 Like

Hi @rbarbosa, @pchristensen,

Could you please help me here?
Thanks

HI Quang Mai

I had a look at the events and what you already have found is right. The ‘path_collection’ is not part of the event payload so you would have to retrieve it if you need it for your application.

One idea to reduce the number of calls would be to cache path for the parent folder of the file which is part of the event payload. That way you would only need to call the api when when you hit a new parent for an uploaded file.

Rgds
Peter