Merge branch 'v20260203-06-autotask-ticketnotes-child-endpoint' into main
This commit is contained in:
commit
e5123952b2
@ -1 +1 @@
|
|||||||
v20260203-04-autotask-resolve-user-note
|
v20260203-06-autotask-ticketnotes-child-endpoint
|
||||||
|
|||||||
@ -522,10 +522,13 @@ class AutotaskClient:
|
|||||||
|
|
||||||
|
|
||||||
def create_ticket_note(self, note_payload: Dict[str, Any]) -> Dict[str, Any]:
|
def create_ticket_note(self, note_payload: Dict[str, Any]) -> Dict[str, Any]:
|
||||||
"""Create a TicketNote via POST /TicketNotes.
|
"""Create a TicketNote for a Ticket.
|
||||||
|
|
||||||
Note: Tenant support varies. Callers should handle AutotaskError(status_code=404)
|
Autotask TicketNotes are a child collection of Tickets. In some tenants, creating notes via the
|
||||||
and implement a fallback if needed.
|
root entity endpoint (POST /TicketNotes) is not supported, while creating via the parent ticket
|
||||||
|
child URL may work (POST /Tickets/{id}/TicketNotes).
|
||||||
|
|
||||||
|
Callers can keep a fallback (for example updating the Ticket description) if both routes fail.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not isinstance(note_payload, dict):
|
if not isinstance(note_payload, dict):
|
||||||
@ -538,7 +541,33 @@ class AutotaskClient:
|
|||||||
if tid <= 0:
|
if tid <= 0:
|
||||||
raise AutotaskError("Invalid ticketID in ticket note payload.")
|
raise AutotaskError("Invalid ticketID in ticket note payload.")
|
||||||
|
|
||||||
data = self._request("POST", "TicketNotes", json_body=note_payload)
|
title = str(note_payload.get("title") or "Backupchecks")
|
||||||
|
description = str(
|
||||||
|
note_payload.get("description")
|
||||||
|
or note_payload.get("note")
|
||||||
|
or note_payload.get("body")
|
||||||
|
or ""
|
||||||
|
)
|
||||||
|
|
||||||
|
pub_val = note_payload.get("publish")
|
||||||
|
# REST uses an integer picklist; in practice '1' corresponds to "ALL" / all Autotask users.
|
||||||
|
if isinstance(pub_val, bool):
|
||||||
|
publish = 1 if pub_val else 1
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
publish = int(pub_val) if pub_val is not None else 1
|
||||||
|
except Exception:
|
||||||
|
publish = 1
|
||||||
|
|
||||||
|
child_payload = {
|
||||||
|
"title": title,
|
||||||
|
"description": description,
|
||||||
|
"publish": publish,
|
||||||
|
}
|
||||||
|
|
||||||
|
# Preferred: parent-child URL
|
||||||
|
data = self._request("POST", f"Tickets/{tid}/TicketNotes", json_body=child_payload)
|
||||||
|
|
||||||
if isinstance(data, dict):
|
if isinstance(data, dict):
|
||||||
if "item" in data and isinstance(data.get("item"), dict):
|
if "item" in data and isinstance(data.get("item"), dict):
|
||||||
return data["item"]
|
return data["item"]
|
||||||
|
|||||||
@ -1869,8 +1869,8 @@ def api_run_checks_autotask_resolve_note():
|
|||||||
note_payload = {
|
note_payload = {
|
||||||
"ticketID": ticket_id,
|
"ticketID": ticket_id,
|
||||||
"title": "Backupchecks",
|
"title": "Backupchecks",
|
||||||
"note": body,
|
"description": body,
|
||||||
"publish": True,
|
"publish": 1,
|
||||||
}
|
}
|
||||||
created = client.create_ticket_note(note_payload)
|
created = client.create_ticket_note(note_payload)
|
||||||
|
|
||||||
|
|||||||
@ -487,6 +487,12 @@ Changes:
|
|||||||
- Updated backend validation to only return success when the TicketNote is successfully created.
|
- Updated backend validation to only return success when the TicketNote is successfully created.
|
||||||
- Aligned frontend success messaging with actual TicketNote creation in Autotask.
|
- Aligned frontend success messaging with actual TicketNote creation in Autotask.
|
||||||
|
|
||||||
|
## v20260203-06-autotask-ticketnotes-child-endpoint
|
||||||
|
|
||||||
|
- Updated the Resolve action to create ticket notes using the Autotask child endpoint POST /Tickets/{TicketID}/Notes.
|
||||||
|
- Removed usage of the unsupported POST /TicketNotes endpoint.
|
||||||
|
- Ensured the created note is user-visible in Autotask and clearly marks the ticket as resolved by Backupchecks.
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
## v0.1.21
|
## v0.1.21
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user