Getting Display value of cmdb ci ServiceNow using Python

2k views Asked by At

I have a code where I need to fetch CMDB Details from servicenow using python

import pysnow
import subprocess
import os
s = pysnow.Client(instance='test', user='admin', 
password='test',request_params={'sysparm_display_value': 'true'})
r = s.query('incident',params={'displayvalue': 'true'}, query=
{'cmdb_ci':'a28cba7a4fb4030028f7fd218110c7f5'})
for record in r.get_multiple(order_by=['-created_on']):
    print(record['cmdb_ci'])

The Output I get is

{u'link': u'https://test.service-now.com/api/now/table/cmdb_ci/a28cba7a4fb40
30028f7fd218110c7f5', u'display_value': u'Server01'}

Is there a way to parse the output further so that I can get the display_value of cmdb_ci?

I tried dv_cmdb_ci,display_value_cmdb_ci and cmdb_ci_display_value. Doesn't work.

Thanks in advance

1

There are 1 answers

0
Anti21 On BEST ANSWER

I used this and got it

print(record['cmdb_ci']['display_value'])