We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

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

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  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

11 REPLIES 11

Try this

 

'https://instancename.service-now.com/api/now/table/u_incident?sysparm_display_value=true&sysparm_query=active=true^u_assignment_group=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 d
Kilo Contributor

Unfortunanetly, I'm getting an empty list:

{'result': []}

I've added .name to the u_assingment_group.name=2e406ceedb532c10fa41a7a8139619,
but I've received incident details from various assginment groups.

Do you have any idea what I'm doing wrong?