- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 06:48 AM
I am trying to close a change ticket, but I cannot seem to get it to close. The ticket is in draft, and I want to immediately close it with a change status as part of automation.
The issue is I cannot figure out how to close it.
Using:
response = requests.patch(sn_url+'/api/sn_chg_rest/v1/change/standard/' + sys_id,
data="{ \"u_close_code\": \"" + "1" + "\", \"u_change_stage\": \"" + "Completed" + "\", \"state\": \"3\" }",
headers=headers)
result_json = json.dumps(response.json(), indent=1)
print(result_json)
It throws:
{
"error": {
"message": "Invalid field.",
"detail": "u_change_stage is read-only."
},
"status": "failure"
}
If I flip around the data in the rest call so that state is listed before u_change_stage, it says that state is read-only and invalid field.
Is this the right way to try and close a ticket? Is there some role issue going on? Anybody seen this issue and know how to address?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 10:20 AM
I had to use another option called updateChange to get this done:
# Open Ticket
response = requests.put(sn_url+'/api/sn_chg_rest/change/updateChange', \
data="{ \
\"values\": { \
\"change\": { \
\"sys_id\": \"" + sys_id + "\", \
\"state\":\"1\" \
} \
} \
}", headers=headers)
I opened the ticket first with the previous json and then ran:
# Close Ticket
response = requests.put(sn_url+'/api/sn_chg_rest/change/updateChange', \
data="{ \
\"values\": { \
\"change\": { \
\"sys_id\": \"" + sys_id + "\", \
\"state\":\"3\", \
\"u_close_code\": \"1\" \
} \
} \
}", headers=headers)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 09:43 AM
you have 2 custom fields that you have to look into (note they start with u_ )
try without those fields, and see if it works. it seems your custom fields are read only and the API can not update them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-04-2022 10:20 AM
I had to use another option called updateChange to get this done:
# Open Ticket
response = requests.put(sn_url+'/api/sn_chg_rest/change/updateChange', \
data="{ \
\"values\": { \
\"change\": { \
\"sys_id\": \"" + sys_id + "\", \
\"state\":\"1\" \
} \
} \
}", headers=headers)
I opened the ticket first with the previous json and then ran:
# Close Ticket
response = requests.put(sn_url+'/api/sn_chg_rest/change/updateChange', \
data="{ \
\"values\": { \
\"change\": { \
\"sys_id\": \"" + sys_id + "\", \
\"state\":\"3\", \
\"u_close_code\": \"1\" \
} \
} \
}", headers=headers)