- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2024 01:04 PM - edited 06-14-2024 01:06 PM
I'm trying to return a set of data from our CMDB table, and it works fine in the API explorer. However, when I run the same query in a python script I'm using, I don't get the the fields I'm asking for.
API Explorer:
Call:
GET https://redacted.servicenowservices.com/api/now/table/u_cmdb_ci_boundary?sysparm_fields=sys_id%2Cnam...
Response:
{
"result": [
{
"sys_id": "2369cc2587408ad030db84840cbb35cb",
"name": "group1"
},
{
"sys_id": "3e1a04e587408ad030db84840cbb3524",
"name": "group2"
},
{
"sys_id": "4539cca187408ad030db84840cbb35ae",
"name": "group3"
},
{
"sys_id": "5f6c262d1bc7b510eab062c6bc4bcbf7",
"name": "group4"
},
{
"sys_id": "6fa79c701b94a8505f7d2020f54bcb61",
"name": "group5"
},
{
"sys_id": "8c9808ad87008ad030db84840cbb3549",
"name": "group6"
},
{
"sys_id": "9c601f201b58b010646b631ee54bcb70",
"name": "group7"
},
{
"sys_id": "a25e434c87604610e51b7627cebb3552",
"name": "group8"
},
{
"sys_id": "a75b4fed1bb5b810caf920efe54bcb2e",
"name": "group9"
},
{
"sys_id": "b00900a187408ad030db84840cbb3561",
"name": "group10"
}
]
}
Python:
Call:
https://redacted.servicenowservices.com/api/now/table/u_cmdb_ci_boundary?sysparm_fields=sys_id%2Cname&sysparm_limit=1
Response:
[{'sys_id': '2369cc2587408ad030db84840cbb35cb'}]
Here's my request code:
def get_boundaries_from_cmbd():
"""
Make an API call to servicenow and retrieve the name and IDs of all
boundaries
"""
api_call = snow_url + ""u_cmdb_ci_boundary?sysparm_fields=sys_id%2Cname&sysparm_limit=1""
response = requests.get(api_call, auth=(
snow_username, snow_password), headers=headers, verify=False)
print(response.json()['result'])
Why is this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2024 06:46 AM
Hi,
Are you using your profile (having admin access) when testing with REST API explorer? Please check if service account 'snow_username' have proper read permissions in u_cmdb_ci_boundary table. For verification purpose, you can also try impersonating with service account and go to the u_cmdb_ci_boundary table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2024 06:46 AM
Hi,
Are you using your profile (having admin access) when testing with REST API explorer? Please check if service account 'snow_username' have proper read permissions in u_cmdb_ci_boundary table. For verification purpose, you can also try impersonating with service account and go to the u_cmdb_ci_boundary table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2024 07:14 AM
That was in fact the issue. By adjusting the permissions on the service account, we're now getting the expected data.
Thank you.