- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2025 08:14 PM
Greetings all. I am trying to get specific data from a JSON payload and am feeling like an id10t since I cannot get what I want. Can I get help from the hivemind? I'm trying to get the user.sid from the jJSON example below
JSON payload example:
{
"queryId": "#get_user_sid",
"executedQuery": "users | where user.ad.email_address in [\"basic.user@somedomain.com\"] | list name, sid",
"rows": 1,
"executionDateTime": "2025-03-12T16:55:38",
"data": [
{
"user.sid": "S-1-5-21-1202660629-999999999-88888888-199364",
"user.name": "userBasic@someDomain"
}
]
}
My current script:
//Set variables
var this_campaign = 'servicenow_test';
var this_user_email = 'conan.lloyd@lazard.com';
//Make Outbound Rest call to get user's Sid
var r_sid = new sn_ws.RESTMessageV2('Nexthink API Access', 'GetUserSid');
r_sid.setStringParameterNoEscape('user_email', this_user_email);
var response_sid = r_sid.execute();
var responseBody_sid = response_sid.getBody();
var responseParse_sid = JSON.parse(responseBody_sid);
gs.info("CDL: item: " + responseParse_sid.data[0].user.sid);
I keep getting undefined. When I change it to gs.info("CDL: item: " + responseParse_sid.data.rows); I get the correct data of 1 back.
Thanks in advance for any help.
~Conan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2025 08:30 PM
Hi @conanlloyd,
Could you please try:
responseParse_sid.data[0]["user.sid"]
var obj = {
"queryId": "#get_user_sid",
"executedQuery": "users | where user.ad.email_address in [\"basic.user@somedomain.com\"] | list name, sid",
"rows": 1,
"executionDateTime": "2025-03-12T16:55:38",
"data": [
{
"user.sid": "S-1-5-21-1202660629-999999999-88888888-199364",
"user.name": "userBasic@someDomain"
}
]
}
gs.info(obj.data[0]["user.sid"]); //S-1-5-21-1202660629-999999999-88888888-199364
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2025 06:48 AM
Hello @conanlloyd
Thank You for marking my response as helpful.
You can also mark it as an accepted solution.
As per the new community features, you can mark multiple response as an accepted solution.
Thank You
Juhi Poddar