Service Now GET incident list by Assignment Group using Python and REST API

i d
Kilo Contributor

Hi, 

I would like to extract all the incident list assigned to specific assignment groups. I have an endpoint like: 

url = 'https://instancename.service-now.com/api/now/table/u_incident'.

When I'm trying to add the sysparm_query, the endopist doesn't react on the provided query. Regarding to this, I have two questions:

1. How to check ID Assignment Group? How sould I put that ID in sysparm_query?

url_test = 'https://instancename.service-now.com/api/now/table/u_incident?sysparm_display_value=true&sysparm_query=active=true^assignment_group.name=12392^state!=7&sysparm_fields=caller_id.email,assigned_to.email,priority,number,sys_created_by,state,active,short_description,assigned_to,sys_created_on,resolved_at,subcategory,close_code,assignment_group,category,sys_created_by,opened_by,category,sys_id,caller_id,sys_updated_on,sys_updated_by'

2. How to create a query for fields like:

  • ['u_assignment_group']
  • ['u_number']
  • ['u_action']
  • ['sys_updated_on']
  • ['u_urgency']
  • ['sys_created_by']
  • ['sys_created_on']
  • ['u_problem_type']
  • ['u_service_offering']
  • ['u_opened_for']
  • ['u_short_description']
  • ['u_contact_type']

Thanks

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can form the encoded query and use it in sysparm_query

Didn't get your question

what's not working?

I could see you are using table as u_incident so are you using correct field names in query

Should it be not u_assignment_group etc?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Hi,

tell somebody from ServiceNow instance team to provide you the script

OR

you can have your own personal instance where you can generate the script

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Use Below sample code for query

number=DPTASK54854462 and u_code = success waived 

I would suggest get the sys_id of the assignment group from servicenow developer and set it as u_assignment_group=<sys_id>

 

url = 'https://instancename/<API Path>/task?number=DPTASK54854462&u_code=success%20waived'

i d
Kilo Contributor

Using this url:

url = 'https://instancename/<API Path>/task?number=DPTASK54854462&u_code=success%20waived'

I'm getting an empty list: 

{'result': []}



Is that correct sys_id?
https://instancename.service-now.com/nav_to.do?uri=%2Fsys_user_group.do%3Fsys_id%3D2e406ceedb532c10fa41a7a8139619,

sys_id = 2e406ceedb532c10fa41a7a8139619

Your URL should be

 

https://instancename.service-now.com/api/now/table/u_incident?u_assignmen t_group=2e406ceedb532c10fa41a7a8139619

i d
Kilo Contributor

Unfortunately, I'm getting the same results using both urls:

url_group = 'https://instancename.service-now.com/api/now/table/u_incident?u_assignment_group.name=2e406ceedb532c10fa41a7a8139619'

 

url_query = 'https://instancename.service-now.com/api/now/table/u_incident?sysparm_display_value=true&sysparm_query=active=true^u_assignment_group.name=2e406ceedb532c10fa41a7a8139619&sysparm_fields=u_assignment_group,u_number,sys_updated_on,u_urgency,sys_created_by,u_contact_type,u_problem_type,u_short_description'

I've tried also with url like:

url_group = 'https://instancename.service-now.com/api/now/table/u_incident?u_assignment_group=2e406ceedb532c10fa41a7a8139619'

but I'm getting an empty list as a result:

{'result': []}

Do you know what I'm doing wrong?

Does it makes sense to extract all the data to the dataframe and then apply the proper filters like u_assingment_group=2e406ceedb532c10fa41a7a8139619?