Skip to main content

Hi.  Is there an API for adding a comment to an existing ticket?  If so, is it documented here?

 

I saw the actual IIQ front-end in the browser making this request when I added a comment, but I don’t think this is a documented request-type…

 

fetch("https://site.incidentiq.com/api/v1.0/tickets/be...ticket-id...6568/activities/new", {

  "headers": {

    "accept": "application/json, text/plain, */*",

    "client": "WebBrowser v1720220859093",

    "content-type": "application/json",

    "productid": "88df910c-91aa-e711-80c2-0004ffa00010",

    "sec-ch-ua": "\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Google Chrome\";v=\"126\"",

    "sec-ch-ua-mobile": "?0",

    "sec-ch-ua-platform": "\"Windows\"",

...

    "Referrer-Policy": "strict-origin-when-cross-origin"

  },

  "body": "{\"TicketId\":\"be...ticket-id...6568\",\"ActivityItems\":.{\"$type\":\"Spark.Shared.Models.TicketActivityComment, Spark.Shared\",\"TicketActivityTypeId\":6,\"ByUserId\":\"4cacdb03-eb45-4e61-b51f-f3695e1ab3f7\",\"Comments\":\"<p>comment 1</p>\"}],\"IsPublic\":false,\"WaitForResponse\":false,\"TicketWasUpdated\":false}",

  "method": "POST"

});

@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

}


Reply