How to pass Dynamic Parameter in REST to pull device information from Azure Intune.

Chetan Mahajan
Kilo Sage
Kilo Sage

Hello Team,

I have a question regarding passing dynamic parameters in a REST Message, specifically when pulling information from Azure Intune. The issue is that the Microsoft graph URI contains spaces, and when trying to use it in ServiceNow, the spaces need to be replaced with %20. For example:

 

Original URL:
```
https://graph.microsoft.com/v1.0/devices?$filter=deviceid eq '0bda714f-78f3-408b-8ebf-5ea165733ff5'
```

URL in ServiceNow:
```
https://graph.microsoft.com/v1.0/devices?$filter=deviceid%20eq%20'0bda714f-78f3-408b-8ebf-5ea165733f...'
```

While the above query works fine, the challenge arises when attempting to pass dynamic parameters. The parameter is populated as `deviceId='xxxxxxxxxx'` instead of `deviceId eq xxxxxxxxx`, causing the data pull to fail. How can this be addressed?
Ref Attachment for error. 

 

1 ACCEPTED SOLUTION

AnveshKumar M
Tera Sage
Tera Sage

Hi @Chetan Mahajan 

 

You can define the end point like the one below.

https://graph.microsoft.com/v1.0/devices?$filter=deviceid%20eq%20'${id}'

 

Then click on the Auto Generate variables related link, so it will generate a variable "id" and you can dynamically pass the 0bda714f-78f3-408b-8ebf-5ea165733ff5 part from script like below.

 

 var r = new sn_ws.RESTMessageV2('Service Graph Connector', 'Default GET');
 r.setStringParameterNoEscape('id', '0bda714f-78f3-408b-8ebf-5ea165733ff5');

 

AnveshKumarM_0-1701260993983.png

 

AnveshKumarM_1-1701261007160.png

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️

 

 

Thanks,
Anvesh

View solution in original post

3 REPLIES 3

AnveshKumar M
Tera Sage
Tera Sage

Hi @Chetan Mahajan 

 

You can define the end point like the one below.

https://graph.microsoft.com/v1.0/devices?$filter=deviceid%20eq%20'${id}'

 

Then click on the Auto Generate variables related link, so it will generate a variable "id" and you can dynamically pass the 0bda714f-78f3-408b-8ebf-5ea165733ff5 part from script like below.

 

 var r = new sn_ws.RESTMessageV2('Service Graph Connector', 'Default GET');
 r.setStringParameterNoEscape('id', '0bda714f-78f3-408b-8ebf-5ea165733ff5');

 

AnveshKumarM_0-1701260993983.png

 

AnveshKumarM_1-1701261007160.png

 

Please mark my answer helpful and accept as a solution if it helped 👍✔️

 

 

Thanks,
Anvesh

Hello @AnveshKumar M ,

          Thank you so much its working now 😊 

Thanks,

Chetan

@Chetan Mahajan I'm glad that it helped 👍

Thanks,
Anvesh