Azure AD B2C Audit Logs - Graph API - query options not working

可紊 提交于 2020-04-16 01:58:06

问题


I am trying to retrieve the Azure AD user sign-in audit logs for our tenant. For this, I am using [Microsoft’s graph APIs][1]

https://graph.microsoft.com/v1.0/auditLogs/signIns?$filter=createdDateTime ge 2019-10-08T09:00:00.0000000 and createdDateTime le 2019-10-08T09:12:00.0000000

In the above-given example, I am trying to filter the logs based on a query option, $filter where I am trying to retrieve the records based on createDateTime,

from Date 2019-10-08T09:00:00.0000000 and to date 2019-10-08T09:12:00.0000000.

Every time I am getting the records from the current time and going back in history. This means, irrespective of any date range I provide, it gets ignored.

For that matter when I apply any OData (https://docs.microsoft.com/en-us/graph/query-parameters#odata-system-query-options) query options ($top, $orderby, etc), the API still returns with the latest audit logs and none of the query options seems to work.

Could this be due to the permissions or the license? Any help is much appreciated.

With the given date ranges I should be able to get the audit logs between the ranges.


回答1:


It works as expected on my side and I don't think it is related with the permissions. Can you paste your whole request here?

Here is mine request:

https://graph.microsoft.com/v1.0/auditLogs/signIns?$filter=createdDateTime le 2019-10-08T09:00:00.0000000Z&$top=1

You can have a try with this one. You can test it by using microsoft graph explorer.

One more thing, we should use /v1.0 instead of /beta version.

APIs under the /beta version in Microsoft Graph are subject to change. Use of these APIs in production applications is not supported.




回答2:


I finally found the answer. I was sending the encoded(HttpUtility.UrlEncode) version of the query options part of the Url, which Graph API doesn’t like for some reason.



来源:https://stackoverflow.com/questions/58384513/azure-ad-b2c-audit-logs-graph-api-query-options-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!