Issue:
I am encountering an issue when using the Microsoft Graph API to fetch audit logs for sign-ins. I want to include a count of the results for pagination purposes, but I am receiving the following error:
"Query option 'Count' is not allowed. To allow it, set the 'AllowedQueryOptions' property on EnableQueryAttribute or QueryValidationSettings."
Code:
const headers = { 'Authorization': "Bearer " + token };
const url = `https://graph.microsoft.com/v1.0/auditLogs/signIns?$filter=startswith(appDisplayName,'Xyz')&$count=true`;
axios
.get(nexturl ?? url, { headers })
.then(async (response) => {
console.log(response, 'log');
const { headers, table } = formatAuditLogs(response.data);
resolve({ headers, table, nextLink: response.data['@odata.nextLink'] });
})
.catch((error) => {
reject(error);
});
Use of $count
in My Case:
I am trying to implement pagination for the audit log results. To do this, I need to include a count of the results so that I can create page navigation (e.g., 1, 2, 3, 4...) for users to jump between pages and keep track of the current page. I have also attempted to use $skip
and $select
, but I encountered the same error regarding AllowedQueryOptions
.
Request for Assistance:
I am seeking guidance on how to resolve this issue and enable the use of $count
or other options for implementing pagination in the Microsoft Graph API. I am using ReactJS for my application and making API calls using Axios.
Any help or insights into how to address this issue would be greatly appreciated. Thank you in advance for your assistance.