简体   繁体   中英

Graph API - use variable in filter query

I am calling the Microsoft Graph API's to import user details into an application (which uses REST based connector) from Azure AD.

The application provides a variable (xyz) to be used in order to do incremental user imports.

I need to pass the application variable as ${xyz}. The Graph query seems to be confused about the $ symbol and is throwing an illegal character exception for the $ sign.

Below is the GET query used:

"https://graph.microsoft.com/v1.0/users?$select=id,displayName,userPrincipalName,mail,accountEnabled,onPremisesLastSyncDateTime&$count=true&$filter=onPremisesLastSyncDateTime%20ge%20${xyz}"

Error: [22;39mjava.lang.IllegalArgumentException: Illegal character in query at index 182:

Have tried to use $$, single quotes,backslash,` etc. to fix the issue, but none worked. Any help would be much appreciated.

As @Dmitry Streblechenko suggested, the error indicates that the variable does not have any real data.

If the real data is passed to the variable, the Graph API call runs successfully

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM