Closing out an issue using the table REST api

sebastiancampos
Giga Contributor

Hello all, I have been trying to close out / resolve an issue using the rest table api.

when I send the patch request I am able to create, and update an issue

resolve = \
{
"caller": "admin",
"resolution_code": "2",
"incident_state": "2",
"close_code": "2",
"resolution_notes": "resolved-test",
"close_notes": "resolved-test",
"resolved_by": "admin",
"resolved_at": str(datetime.datetime.now()),
}

Sending this updates the closed notes, resolution notes, etc.

But when I try to send it with a resolution code 6 or 7 to set it to closed,

I get the following error:
```
'error': {'message': 'Operation Failed',
'detail': 'Data Policy Exception: \n\tThe following fields are mandatory: Resolution code'},
'status': 'failure'}
```
This occurs when I do it through the REST api explorer as well. 

I am currently using an instance running Utah

4 REPLIES 4

Giles Lewis
Giga Guru

"2" is not a valid value for close_code (aka Resolution code). Examples of valid close_code values from a PDI are "Duplicate", "Known error", "No resolution provided", "Resolved by caller", "Solution provided", "Workaround provided", "User error". The values in your instance may be different.

KB18
Tera Guru
Tera Guru

Hi Sebastian,

Error you are getting because of the wrong value passing in the Resolution code which is mandatory field checking data policy.

Please use the below payload:

 

{
"caller": "admin",
"resolution_code": "Known error",
"incident_state": "2",
"close_code": "2",
"resolution_notes": "resolved-test",
"close_notes": "resolved-test",
"resolved_by": "system",
"resolved_at": str(datetime.datetime.now()),
}


KB18_0-1683099388075.png

 

 

Resolution code

Please hit the thumb Icon and mark as correct in case I help you with your query!!!
- Kailas

KB18
Tera Guru
Tera Guru

Dear Sebanstian,

I hope your issue has been resolved. If not, feel free to reach out me. I am happy to help.

 

 

Please hit the thumb Icon and mark as correct in case I help you with your query!!!
- Kailas

automateyournet
Giga Contributor

I have this issue as well when I try to curl to resolve a problem like this: 

curl -X PATCH "https://service-now.com/api/now/table/problem/bd27af94c3bb12104fcb1933e40131a6" \ --header "Accept: application/json" \ --header "Content-Type: application/json" \ --user "admin:password" \ --data '{ "problem_state": "107", "active": "false", "assigned_to": "6816f79cc0a8016401c5a33be04be441", "resolution_code": "fix_applied", "resolved_by": "6816f79cc0a8016401c5a33be04be441", "resolved_at": "2025-02-14 22:50:00", "resolution_notes": "Enabled the Ethernet0/0.10 interface on Router R1, restoring connectivity between PC1 and PC2.", "close_notes": "Problem resolved successfully.", "work_notes": "Closing issue: Enabled Ethernet0/0.10 on Router R1, PC1 to PC2 connectivity restored." }'

I get this error 
The following fields are mandatory: Resolution code"},"status":"failure"}


But I am passing it a valid resolution code?