Office 365 Management Activity API - Query using User ID or File ID

Solution 1:

Unfortunately filtering by AuditRecord (content blob) UserId or ObjectId property is not supported via Office 365 Management Activity API endpoint, only the following parameters are supported:

  • contentType
  • startTime and endTime

The workaround would to be to filter results on the client side as demonstrated below:

Example

const requestUrl = `https://manage.office.com/api/v1.0/${tenantId}/activity/feed/audit/${contentId}$audit_sharepoint$Audit_SharePoint`;
const options = {
   method: 'GET',
   headers: {
      "Content-Type": "application/json; charset=utf-8",
      "Authorization": "bearer " + accessToken
   }
};

const rawResponse = await fetch(requestUrl,options);
const blobs = await rawResponse.json(); //get all blobs

const blobsByUser = blobs.filter(blob => {
    return blob.UserId === "[email protected]";
})