Forum Discussion

Yogi4's avatar
Yogi4
Copper Contributor
Feb 28, 2020
Solved

Can we create Tag inside Team using graph api?

Can we create Tag inside Team using graph api?

5 Replies

  • Smith_J's avatar
    Smith_J
    Brass Contributor

    You need to include entities, with type 'mention', in your message and the message of the text should include <at>username</at> for each entity mentioned.

    EDIT 1: When using https://graph.microsoft.com/beta/teams/{team-id}/channels/{channel-id}/messages on graph explorer

    {

    "error": {

    "code": "BadRequest",

    "message": "Value cannot be null.\r\nParameter name: Content",

    "innerError": {

    "request-id": "f0d4fed8-7726-4338-8a68-9685a690eab5",

    "date": "2019-07-02T12:46:14"

    }

    }

    }

    • ChetanSharma-msft's avatar
      ChetanSharma-msft
      Icon for Microsoft rankMicrosoft

      Yogi4 - Now you can create/Get teams tags using Beta Graph API.
      Reference doc: Create teamworkTag - Microsoft Graph beta | Microsoft Docs

      You can also get the created tags using below Beta Graph API:
      GET /teams/{team-Id}/tags
      List teamworkTags - Microsoft Graph beta | Microsoft Docs

      You can also send the message with mentioning teams tag using below API
      Post request: https://graph.microsoft.com/v1.0/teams/{team id}/channels/{channel id}/messages

      Message body:
      {
      "subject": "This is very urgent!",
      "importance": "urgent",
      "body": {
      "contentType": "html",
      "content": "Programmatically mentioning of Tagged users <at id=\"0\">String_1234</at>"
      },
      "mentions": [
      {
      "id": 0,
      "mentionText": "String_1234",
      "mentioned": {
      "tag": {
      "@odata.type": "#microsoft.graph.teamworkTagIdentity",
      "id": "", //tag id
      "displayName": "" // tag name
      }
      }
      }
      ]
      }

      Thanks!!

      • _WKU_'s avatar
        _WKU_
        Copper Contributor

        ChetanSharma-msft 

        Hi there,

        Creating tags isn't working, tried PA funtion and Rest API. I always get the error

         

        {
            "statusCode": 409,
            "headers": {
                "Transfer-Encoding": "chunked",
                "Vary": "Accept-Encoding",
                "Strict-Transport-Security": "max-age=31536000",
                "request-id": "e0a71003-xxx-3d2b4ecb792f",
                "client-request-id": "e0a71003-xxx-3d2b4ecb792f",
                "x-ms-ags-diagnostic": "{\"ServerInfo\":{\"DataCenter\":\"West Europe\",\"Slice\":\"E\",\"Ring\":\"5\",\"ScaleUnit\":\"002\",\"RoleInstance\":\"AM2PEPF0001F036\"}}",
                "Date": "Mon, 12 Feb 2024 11:22:00 GMT",
                "Content-Type": "application/json"
            },
            "body": {
                "error": {
                    "code": "Conflict",
                    "message": "UnknownError",
                    "innerError": {
                        "date": "2024-02-12T11:22:00",
                        "request-id": "e0a71003-xxx-3d2b4ecb792f",
                        "client-request-id": "e0a71003-xxx-3d2b4ecb792f"
                    }
                }
            }
        }

         

         
        This is my HTTP post

         

        {
            "uri": "https://graph.microsoft.com/v1.0/teams/2cb01ad0-xxx-66f91a63cbba/tags",
            "method": "POST",
            "headers": {
                "Content-Type": "application/json"
            },
            "authentication": {
                "authority": "https://login.microsoft.com",
                "tenant": "9848535f-xxx-1f82d3bd14d1",
                "audience": "https://graph.microsoft.com",
                "clientId": "fd912418-xxx-a8167630599e",
                "secret": "*sanitized*",
                "type": "ActiveDirectoryOAuth"
            },
            "body": {
                "displayName": "AAW",
                "members": [
                    {
                        "userId": "78d481c1-66f9-4d30-9000-db76d9cb89bd"
                    }
                ]
            }
        }

         

         
        Does anybody has a clue?

Resources