Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

Getting Error Illegal character in query REST AddAccessJSON

prajakta
Regular Contributor
Regular Contributor

Hi, 

We need to perform 2 API calls in AddAccessJSON of REST connector. 

1. GET - https://graph.microsoft.com/beta/devices?$search="displayName:MachineName"

2. POST - https://graph.microsoft.com/v1.0/groups/groupID/members/$ref

The #1 API URL is not getting resolved. Following options are attempted 

1. "url": "https://graph.microsoft.com/beta/devices?$search=%22displayName%3A'${account.accountID}'%22",
[error:Error Illegal character in query at index 68:
https://graph.microsoft.com/beta/devices?$search=%22displayName%3A'${account.accountID}'%22]

2. "url": "https://graph.microsoft.com/beta/devices?$search=%22displayName%3A${account.accountID}%22",
[error:Error Illegal character in query at index 67:
https://graph.microsoft.com/beta/devices?$search=%22displayName%3A${account.accountID}%22]

3. "url": "https://graph.microsoft.com/beta/devices?$search=\"displayName:${account.accountID}\"",
error:Error Illegal character in query at index 49:
https://graph.microsoft.com/beta/devices?$search="displayName:${account.accountID}"]

Upon hardcoding the value for ${account.accountid} the API is getting invoked successfully. 

Kindly provide suggestions in order resolve this issue.

Thanks,

Prajakta

 

 

 

 

13 REPLIES 13

NM
Honored Contributor III
Honored Contributor III

@prajakta can you share prov logs?


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

prajakta
Regular Contributor
Regular Contributor

2024-10-23T14:19:02+05:30-ecm-worker-rest.RestProvisioningService-quartzScheduler_Worker-12-m9725-DEBUG-Calling Webservice Url - https://graph.microsoft.com/beta/devices?$search="displayName:${account.accountID}" with httpParams - null
2024-10-23T14:19:02+05:30-ecm-worker-rest.RestProvisioningService-quartzScheduler_Worker-12-m9725-DEBUG-Got Webservice API Response: [error:Error Illegal character in query at index 49: https://graph.microsoft.com/beta/devices?$search="displayName:${account.accountID}"]
2024-10-23T14:19:02+05:30-ecm-worker-rest.RestUtilService-quartzScheduler_Worker-12-m9725-DEBUG-Got null response statusCode with erroMsg - [error:Error Illegal character in query at index 49: https://graph.microsoft.com/beta/devices?$search="displayName:${account.accountID}"]
2024-10-23T14:19:02+05:30-ecm-worker-rest.RestProvisioningService-quartzScheduler_Worker-12-m9725-DEBUG-addAccessJSON: [call:[[name:Groups, connection:userAuth, url:https://graph.microsoft.com/beta/devices?$search="displayName:${account.accountID}", httpMethod:GET, httpHeaders:[Authorization:${access_token}, ConsistencyLevel:eventual], httpContentType:application/json, successResponses:[statusCode:[200]]], [name:Groups, connection:userAuth, url:https://graph.microsoft.com/v1.0/groups/${entitlementValue.entitlementID}/members/\$ref, httpParams:{"@odata.id":"https://graph.microsoft.com/v1.0/directoryObjects/${response.Groups.message.value[0].id}"}, httpMethod:POST, httpHeaders:[Authorization:${access_token}], httpContentType:application/json, successResponses:[statusCode:[200]]]]]
2024-10-23T14:19:02+05:30-ecm-worker-rest.RestProvisioningService-quartzScheduler_Worker-12-m9725-DEBUG-params.memento.addAccessJSON : [call:[[name:Groups, connection:userAuth, url:https://graph.microsoft.com/beta/devices?$search="displayName:${account.accountID}", httpMethod:GET, httpHeaders:[Authorization:${access_token}, ConsistencyLevel:eventual], httpContentType:application/json, successResponses:[statusCode:[200]]], [name:Groups, connection:userAuth, url:https://graph.microsoft.com/v1.0/groups/${entitlementValue.entitlementID}/members/\$ref, httpParams:{"@odata.id":"https://graph.microsoft.com/v1.0/directoryObjects/${response.Groups.message.value[0].id}"}, httpMethod:POST, httpHeaders:[Authorization:${access_token}], httpContentType:application/json, successResponses:[statusCode:[200]]]]]
2024-10-23T14:19:02+05:30-ecm-worker-rest.RestProvisioningService-quartzScheduler_Worker-12-m9725-DEBUG-currentEntitlementJsonMap : [call:[[name:Groups, connection:userAuth, url:https://graph.microsoft.com/beta/devices?$search="displayName:${account.accountID}", httpMethod:GET, httpHeaders:[Authorization:${access_token}, ConsistencyLevel:eventual], httpContentType:application/json, successResponses:[statusCode:[200]]], [name:Groups, connection:userAuth, url:https://graph.microsoft.com/v1.0/groups/${entitlementValue.entitlementID}/members/\$ref, httpParams:{"@odata.id":"https://graph.microsoft.com/v1.0/directoryObjects/${response.Groups.message.value[0].id}"}, httpMethod:POST, httpHeaders:[Authorization:${access_token}], httpContentType:application/json, successResponses:[statusCode:[200]]]]] | entitlementname: Groups
2024-10-23T14:19:02+05:30-ecm-worker-rest.RestProvisioningService-quartzScheduler_Worker-12-m9725-DEBUG-currentEntitlementJsonMap : [call:[[name:Groups1, connection:userAuth, url:https://graph.microsoft.com/beta/devices?$search="displayName:${account.accountID}", httpMethod:GET, httpHeaders:[Authorization:${access_token}, ConsistencyLevel:eventual], httpContentType:application/json, successResponses:[statusCode:[200]]], [name:Groups2, connection:userAuth, url:https://graph.microsoft.com/v1.0/groups/${entitlementValue.entitlementID}/members/\$ref, httpParams:{"@odata.id":"https://graph.microsoft.com/v1.0/directoryObjects/${response.Groups.message.value[0].id}"}, httpMethod:POST, httpHeaders:[Authorization:${access_token}], httpContentType:application/json, successResponses:[statusCode:[200]]]]]
2024-10-23T14:19:02+05:30-ecm-worker-rest.RestProvisioningService-quartzScheduler_Worker-12-m9725-DEBUG-params.memento.addAccessJSON: [call:[[name:Groups1, connection:userAuth, url:https://graph.microsoft.com/beta/devices?$search="displayName:${account.accountID}", httpMethod:GET, httpHeaders:[Authorization:${access_token}, ConsistencyLevel:eventual], httpContentType:application/json, successResponses:[statusCode:[200]]], [name:Groups2, connection:userAuth, url:https://graph.microsoft.com/v1.0/groups/${entitlementValue.entitlementID}/members/\$ref, httpParams:{"@odata.id":"https://graph.microsoft.com/v1.0/directoryObjects/${response.Groups.message.value[0].id}"}, httpMethod:POST, httpHeaders:[Authorization:${access_token}], httpContentType:application/json, successResponses:[statusCode:[200]]]]]

NM
Honored Contributor III
Honored Contributor III

Try this @prajakta 

url:https://graph.microsoft.com/beta/devices?$search=\"displayName%3A${account.accountID}\", 


If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'

prajakta
Regular Contributor
Regular Contributor

Appreciate your quick response.  Getting similar error for

"url": "https://graph.microsoft.com/beta/devices?$search=\"displayName%3A${account.accountID}\"",

 

2024-10-23T16:09:14+05:30-ecm-worker-rest.RestProvisioningService-quartzScheduler_Worker-13-m9725-DEBUG-params.memento.addAccessJSON: [call:[[name:Groups1, connection:userAuth, url:https://graph.microsoft.com/beta/devices?$search="displayName%3A${account.accountID}", httpMethod:GET, httpHeaders:[Authorization:${access_token}, ConsistencyLevel:eventual], httpContentType:application/json, successResponses:[statusCode:[200]]], [name:Groups2, connection:userAuth, url:https://graph.microsoft.com/v1.0/groups/${entitlementValue.entitlementID}/members/\$ref, httpParams:{"@odata.id":"https://graph.microsoft.com/v1.0/directoryObjects/${response.Groups.message.value[0].id}"}, httpMethod:POST, httpHeaders:[Authorization:${access_token}], httpContentType:application/json, successResponses:[statusCode:[200]]]]]
 
2024-10-23T16:09:14+05:30-ecm-worker-rest.RestProvisioningService-quartzScheduler_Worker-13-m9725-DEBUG-Calling Webservice Url - https://graph.microsoft.com/beta/devices?$search="displayName%3A${account.accountID}" with httpParams - null
 
2024-10-23T16:09:14+05:30-ecm-worker-rest.RestProvisioningService-quartzScheduler_Worker-13-m9725-DEBUG-Got Webservice API Response: [error:Error Illegal character in query at index 49: https://graph.microsoft.com/beta/devices?$search="displayName%3A${account.accountID}"]

Please share full JSON


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

here is the JSON 

{
"call": [
{
"name": "Groups",
"connection": "userAuth",
"url": "https://graph.microsoft.com/beta/devices?$search=%22displayName:+${account.accountID}%22",
"httpMethod": "GET",
"httpHeaders": {
"Authorization": "${access_token}",
"ConsistencyLevel": "eventual"
},
"httpContentType": "application/json",
"successResponses": {
"statusCode": [
200
]
}
},
{
"name": "Groups",
"connection": "userAuth",
"url": "https://graph.microsoft.com/v1.0/groups/${entitlementValue.entitlementID}/members/\\$ref",
"httpParams": "{\"@odata.id\":\"https://graph.microsoft.com/v1.0/directoryObjects/${response.Groups.message.value[0].id}\"}",
"httpMethod": "POST",
"httpHeaders": {
"Authorization": "${access_token}"
},
"httpContentType": "application/json",
"successResponses": {
"statusCode": [
200
]
}
}
]
}

Did you validated with hardcoded values ?


Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

Yes the first GET API call goes through successfully and it does fail for 2nd. But with accountID the API itself is not getting invoked.

{
  "call": [
    {
      "name": "Groups",
      "connection": "userAuth",
      "url": "https://graph.microsoft.com/beta/devices?$search=%22displayName%3A${URLEncoder.encode(account.accountID, 'UTF-8')}%22",
      "httpMethod": "GET",
      "httpHeaders": {
        "Authorization": "${access_token}",
        "ConsistencyLevel": "eventual"
      },
      "httpContentType": "application/json",
      "successResponses": {
        "statusCode": [
          200
        ]
      }
    },
    {
      "name": "Groups",
      "connection": "userAuth",
      "url": "https://graph.microsoft.com/v1.0/groups/${entitlementValue.entitlementID}/members/\\$ref",
      "httpParams": "{\"@odata.id\":\"https://graph.microsoft.com/v1.0/directoryObjects/${response.Groups.message.value[0].id}\"}",
      "httpMethod": "POST",
      "httpHeaders": {
        "Authorization": "${access_token}"
      },
      "httpContentType": "application/json",
      "successResponses": {
        "statusCode": [
          200
        ]
      }
    }
  ]
}

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

prajakta
Regular Contributor
Regular Contributor

Thanks Rushikesh, getting below error for above JSON 

 

2024-10-23T19:40:18+05:30-ecm-worker-rest.RestUtilService-quartzScheduler_Worker-9-m9725-DEBUG-Got null response statusCode with erroMsg - [error:Error Illegal character in query at index 67: https://graph.microsoft.com/beta/devices?$search=%22displayName%3A${URLEncoder.encode(account.accoun..., 'UTF-8')}%22]
 
2024-10-23T19:40:18+05:30-ecm-worker-rest.RestProvisioningService-quartzScheduler_Worker-9-m9725-DEBUG-Calling Webservice Url - https://graph.microsoft.com/beta/devices?$search=%22displayName%3A${URLEncoder.encode(account.accoun..., 'UTF-8')}%22 with httpParams - null

{
  "call": [
    {
      "name": "Groups",
      "connection": "userAuth",
      "url": "https://graph.microsoft.com/beta/devices?$search=%22displayName%3A${account.accountID.replace(':', '%3A').replace(' ', '%20')}%22",
      "httpMethod": "GET",
      "httpHeaders": {
        "Authorization": "${access_token}",
        "ConsistencyLevel": "eventual"
      },
      "httpContentType": "application/json",
      "successResponses": {
        "statusCode": [
          200
        ]
      }
    },
    {
      "name": "Groups",
      "connection": "userAuth",
      "url": "https://graph.microsoft.com/v1.0/groups/${entitlementValue.entitlementID}/members/\\$ref",
      "httpParams": "{\"@odata.id\":\"https://graph.microsoft.com/v1.0/directoryObjects/${response.Groups.message.value[0].id}\"}",
      "httpMethod": "POST",
      "httpHeaders": {
        "Authorization": "${access_token}"
      },
      "httpContentType": "application/json",
      "successResponses": {
        "statusCode": [
          200
        ]
      }
    }
  ]
}

Regards,
Rushikesh Vartak
If this helped you move forward, click 'Kudos'. If it solved your query, select 'Accept As Solution'.

No luck yet.

 

2024-10-23T19:51:37+05:30-ecm-worker-rest.RestProvisioningService-quartzScheduler_Worker-4-m9725-DEBUG-Calling Webservice Url - https://graph.microsoft.com/beta/devices?$search=%22displayName%3A${account.accountID.replace(':', '%3A').replace(' ', '%20')}%22 with httpParams - null
 
2024-10-23T19:51:37+05:30-ecm-worker-rest.RestProvisioningService-quartzScheduler_Worker-4-m9725-DEBUG-Got Webservice API Response: [error:Error Illegal character in query at index 67: https://graph.microsoft.com/beta/devices?$search=%22displayName%3A${account.accountID.replace(':', '%3A').replace(' ', '%20')}%22]

prajakta
Regular Contributor
Regular Contributor

Is it because of " before displayname the $ is not getting resolved? 

Also the accountId  is alphanumeric field without any special characters