cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Insert comment through Teams

Biaggio
Observer

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?

Biaggio_1-1678451130748.png

Biaggio_2-1678451151620.png

 

5 REPLIES 5

michiel_otten
Mentor

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" }


#Performance matter!

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.

 

Biaggio_2-1679435557826.png

 

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}}\"}"
}
]
}
]
}

#Performance matter!

Thank you very much. It worked.

radek_jasinski
DynaMight Guru
DynaMight Guru

Hi,

I agree with Michiel. You should add:

  • Content-Type: application/json
  • "message": "string"
  • "context": "string"

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\"}"

comment.png

Have a nice day!

Featured Posts