Guys, does anyone know if it's possible to insert a comment in my problem, through Teams? I'm calling the Dyna API, passing the body, but it's not working. Has anyone ever done something like this?
Solved! Go to Solution.
So a few things what you could try
- adding a content type (application/json)
- i'm not sure your posting a valid json in your body. Should be something like this:
{ "message": "string", "context": "string" }
I already tried that. The problem here is being configured in a way that Dynatrace understands that the content of my input is what should be sent. I've tried to pass the body in several ways. An example is below:
"body":"{\"message\":\"string\",\"context\":\"string\"}={{comment.value}}"
This is just an example, to show that you need to pass the
={{comment.value}}"
With the intention that it takes the input data entered in Teams and makes the post.
Tested it out, this worked for me.
{
"@type": "MessageCard",
"summary": "{PID}}",
"potentialAction": [
{
"@type": "ActionCard",
"name": "Add a comment",
"inputs": [
{
"@type": "TextInput",
"id": "note",
"isMultiline": true,
"title": "Add note here..."
}
],
"actions": [
{
"@type": "httpPost",
"method":"POST",
"name": "OK",
"title": "Submit",
"headers": [
{
"name": "Authorization",
"value": ""
},
{
"name": "Content-type",
"value": "application/json"
}
],
"target": "https:\/\/[URL]\/e\/[ENVID]\/api\/v2\/problems\/[PID]\/comments?api-token=[API-TOKEN]",
"body": "{\"message\":\"{{note.value}}\"}"
}
]
}
]
}
Thank you very much. It worked.
Hi,
I agree with Michiel. You should add:
Like you can see here: https://www.dynatrace.com/support/help/dynatrace-api/environment-api/problems-v2/comments/post-comme...
For example I add the correct curl below:
curl -X POST “{env_id}/api/v2/problems/{problemID}/comments" -H "accept: */*" -H "Authorization: Api-Token {token}" -H "Content-Type: application/json; charset=utf-8" -d "{\"message\":\"Example Message\",\"context\":\"Community\"}"