PSYNOW Python module - How to search sys_user table when sys_id is known

GlenC
Kilo Explorer

Hello All:

 

    I'm using the python module PYSNOW and I need some assistance trying to search the sys_user table when I know the sys_id. Can someone provide an example using the query builder?

Here is what I have tried to use....

sys_user= c.resource(api_path='/table/sys_user')
userData=sys_user.get(query={'sys_id':'837482ea827383748273'}) [FAKE sys_id of course]

I'm not even sure type kind of class userData would become. I'm not a programmer and more of a python hack. Just write stuff to get something done.

If someone could provide a sample of how to retrieve this data that would be great. I'm basically trying to get the users full name from the table.

Thanks

GlenC

 

2 REPLIES 2

mmaraj1
Mega Expert
import pysnow

# Create client object
c = pysnow.Client(instance='myinstance', user='myusername', password='mypassword')

# Define a resource, here we'll use the usertable table API
incident = c.resource(api_path='/table/sys_user')

# Query for incident with number username
response = incident.get(query={'user_name': 'enter username.sysid'})

# Print out the matching record
print(response.one())

mmaraj1
Mega Expert

I actually didn't know about the pysnow module until i saw your post. this is interesting . thanks 🙂