@AKennis 77b3f7 ouboces Thank you for submitting your question to our community!
At this time, you cannot add a comment via API via our documentation. This would be a great idea to add to our Idea Exchange. You can add this here: https://community.incidentiq.com/ideas
There’s a lot that’s not documented, but you are on the right track. I’ve had to do the same thing to figure out how to add comments, etc.
That is the correct endpoint URL. Here is what works for me:
{
headers: {
"SiteId": "{your site ID}",
"Authorization": "Bearer {your API token}",
"Pragma": "no-cache",
"Accept": "application/json, text/plain, */*",
"Client": "WebBrowser",
"Accept-Encoding": "gzip, deflate",
"Content-Type": "application/json",
}
}
{
"TicketId": "{TicketId}",
"ActivityItems": I
{
"$type": "Spark.Shared.Models.TicketActivityComment, Spark.Shared",
"TicketActivityTypeId": 6,
"Comments": "Your comment goes here"
}
],
"IsPublic": {boolean}, /* This is the 'Visible to Requestor' toggle */
"WaitForResponse": {boolean}, /* This is the 'Waiting on Requestor' toggle */
"TicketWasUpdated": {boolean} /* I believe this will determine whether or not a "when updated" rule will fire, or an "update" email to the requestor/followers */
}
Thanks a lot @jclark , and thank you too @Kathryn Carter . I got commenting to work using the /tickets/{TicketId}/activities/new call (as yet undocumented).
Here’s Go code for that:
type CommentOnTicketReq struct {
IiqApiKey string
TicketId string
Comment string
WaitForResponse bool
}
func CommentOnTicket(req CommentOnTicketReq) error {
type activityItem struct {
DollarType string `json:"$type"`
TicketActivityTypeId int
Comments string
}
type commentOnTicketPayload struct {
TicketId string
ActivityItems ]activityItem
IsPublic bool
WaitForResponse bool
TicketWasUpdated bool
}
payload := commentOnTicketPayload{
TicketId: req.TicketId,
ActivityItems: ]activityItem{
{
DollarType: "Spark.Shared.Models.TicketActivityComment, Spark.Shared",
TicketActivityTypeId: 6,
Comments: req.Comment,
},
},
IsPublic: true,
WaitForResponse: req.WaitForResponse,
TicketWasUpdated: true,
}
payloadData, err := json.Marshal(payload)
if err != nil {
return err
}
uri := fmt.Sprintf("tickets/%s/activities/new", req.TicketId)
iiqReq, err := initIiqReq(req.IiqApiKey, http.MethodPost, uri, string(payloadData))
if err != nil {
return err
}
res, err := http.DefaultClient.Do(iiqReq)
if err != nil {
return err
}
defer res.Body.Close()
resBody, err := io.ReadAll(res.Body)
if err != nil {
return err
}
if res.StatusCode < 200 || res.StatusCode > 299 {
return fmt.Errorf("/tickets/ticket-id/activities/new responsed with unexpected status code %d, body %s", res.StatusCode, string(resBody))
}
return nil
}