Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to create an incident with the assignment_group field set using the REST Table API?

Mike Williams1
Kilo Contributor

Hi,

I'm building an integration with Service Now. I am trying to create an incident ticket in Service Now using the REST Table API. I have read the documentation here that describes creating an incident and I can create an incident where I do not set the assignment group of the ticket. 

When I try to create an incident with the assignment group set using the following POST body as an example:

POST https://xxxxx.service-now.com/api/x_xxxxx_xxxx/inbound

{
    "action": "insert",
    "type": "incident",
    "payload": {
        "correlation_id": "d87d1554-8386-45d5-9464-b4bb8f062a6d",
        "short_description": " Test__20180612_113606",
        "assignment_group": "f78e31a80f80d740e32a5d78a1050eb1",
        "company": "Oltiva",
        "description": "This is a test SR",
        "impact": "1",
        "state": "1",
        "urgency": "2"
    }
}

I get the following error:

{
    "result": {
        "success": false,
        "message": "Invalid assignment_group: f78e31a80f80d740e32a5d78a1050eb1"
    }
}

However, I can run a GET request against the sys_user_group table:

https://xxxxx.service-now.com/api/now/table/sys_user_group/f78e31a80f80d740e32a5d78a1050eb1

That GET request returns the specified assignment group as expected, meaning that is the correct sys_id of the assignment group.

How can I create an incident with the assignment group set correctly? 

 

3 REPLIES 3

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Replace the sys_id of the assignment group with the group name instead and it should work. This is totally fine since group name are unique in ServiceNow.

 

//Göran

Mike Williams1
Kilo Contributor

Thanks for the reply Goran. I have tried that but I get the same error. For example, with this POST body:

POST https://xxxxx.service-now.com/api/x_xxxxx_xxxxxxxx/inbound

{
    "action": "insert",
    "type": "incident",
    "payload": {
        "correlation_id": "d87d1554-8386-45d5-9464-b4bb8f062a6d",
        "short_description": " Test__20180612_113606",
        "assignment_group": "MyTestGroup",
        "company": "Oltiva",
        "description": "This is a test SR",
        "impact": "1",
        "state": "1",
        "urgency": "2"
    }
}

I get the following response:

{
    "result": {
        "success": false,
        "message": "Invalid assignment_group: MyTestGroup"
    }
}

I can look up that assignment group by name using the following GET request:

https://xxxxx.service-now.com/api/now/table/sys_user_group?sysparm_query=name=MyTestGroup

Are there other considerations that might cause that error beyond supplying an invalid value for that property? 

I tested it through the REST API Explorer in the instance and it worked directly like this:
find_real_file.png

 

have you tried to do it with a different user like admin, just to rule out Access problems?

//Göran