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

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

Hi Ankur, 

 

You're right! I've formed the query based on the endpoint fields:

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

 

But the u_assignment_group.name doesn't react, still, I'm getting all the data from various assigned groups. Could you please navigate me how to check the Assignment Group name (id number)? I've tried to use statement LIKE in the sysparm_query, with the regular Assignment Group name, but doesn't work.

suvro
Mega Sage
Mega Sage

You can use REST API explorer to mimic your requirement. You have the option to convert that request in Python, CURL etc

 

find_real_file.png

i d
Kilo Contributor

Thanks, but I haven't access in the SNOW UI to the REST API explorer. I have received only the endpoint 🙂