Jesvin
Jesvin

Reputation: 21

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.

Upvotes: 0

Views: 924

Answers (1)

RamaraoAdapa
RamaraoAdapa

Reputation: 3137

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

Upvotes: 0

Related Questions