How do I push or add comments to problems?

You can share insights related to remediation actions or additional information about possible root causes by attaching comments to detected problems. The problem comments REST endpoint enables third party integrations to push comments to existing problems or to share the collected feed of comments through the API.

There are two ways to push comments to an existing problem. The typical approach to add comments to problems is to use the problem details page, as shown below.

Use the following HTTP GET request to retrieve the comments feed for a given problem:

https://{id}.live.dynatrace.com/api/v1/problem/details/{PID}/comments

The following example shows the result of a successful call to a problem's comments feed:

{
  comments: [
    {
      id: -5785321710852868000,
      createdAtTimestamp: 1477561321162,
      content: "My UI comment. This is a known issue caused by a backup process run.",
      userName: "wolfgang@email.com",
      context: null
    },
    {
      id: -2656985228510593500,
      createdAtTimestamp: 1474543966351,
      content: "This is a comment with an [inline-style link](https://www.google.com).",
      userName: "Wolfgang",
      context: "Slack"
    }
  ]
}

Use an HTTP POST request to create a new comment for an existing problem: https://{id}.live.dynatrace.com/api/v1/problem/details/{PID}/comments

The payload must contain the following JSON-encoded message, where the user attribute shows which user sent the comment and the context attribute shows the comments source. The example below shows a comment that the user Wolfgang has sent through the Slack team chat system to Dynatrace:

{  
  "comment" : "Contains the actual comment text with an [inline-style link](https://www.google.com).",
  "user" : "Wolfgang",
  "context" : "Slack"
}

Use the following HTTP DELETE request to delete an existing comment. Replace {PID} with the problem's unique ID and {CID} with the comment's unique ID:

https://{id}.live.dynatrace.com/api/v1/problem/details/{PID}/comments/{CID}

Use an HTTP PUT request to edit and change an existing comment where the payload message is the same as for the POST call. Replace {PID} with the problem's unique ID and {CID} with the comment's unique ID:

https://{id}.live.dynatrace.com/api/v1/problem/details/{PID}/comments/{CID}