Merge branch 'v20260203-06-autotask-ticketnotes-child-endpoint' into main

This commit is contained in:
Ivo Oskamp 2026-02-06 13:23:31 +01:00
commit e5123952b2
4 changed files with 64 additions and 29 deletions

View File

@ -1 +1 @@
v20260203-04-autotask-resolve-user-note
v20260203-06-autotask-ticketnotes-child-endpoint

View File

@ -522,10 +522,13 @@ class AutotaskClient:
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)
and implement a fallback if needed.
Autotask TicketNotes are a child collection of Tickets. In some tenants, creating notes via the
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):
@ -538,7 +541,33 @@ class AutotaskClient:
if tid <= 0:
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 "item" in data and isinstance(data.get("item"), dict):
return data["item"]

View File

@ -1869,8 +1869,8 @@ def api_run_checks_autotask_resolve_note():
note_payload = {
"ticketID": ticket_id,
"title": "Backupchecks",
"note": body,
"publish": True,
"description": body,
"publish": 1,
}
created = client.create_ticket_note(note_payload)

View File

@ -487,6 +487,12 @@ Changes:
- Updated backend validation to only return success when the TicketNote is successfully created.
- 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