3

I am using v2.0.1 of servicenow from PyPi to interact with ServiceNow. I need to be able to look up a user in the sys_user table so I can find the sys_id assigned to them. If anyone has some sample code they can share it would be appreciated.

I have tried using the following with no success:

from servicenow import Connection
from servicenow import ServiceNow

conn = conn = Connection.Auth(username='abc', password='xyz', instance='demo')
user = ServiceNow.Base(conn)
user.__table__ = 'sys_user.do'

rec = user.fetch_all({'user_name': 'abc123'})

This fails with

AttributeError: 'Base' object has no attribute 'fetch_all'
Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
DanEhrlich
  • 111
  • 1
  • 1
  • 3

1 Answers1

0

I am not familiar with PyPi, but I will tell you you can make standard REST calls to the /api/now/table/sys_user?sysparm_query=user_nameSTARTSWITH

Also, make sure to review the notes regarding JSON, JSONv2, vs SOAP and use the right connection auth string

Stegel
  • 11
  • 5