Search code examples
microsoft-graph-apimicrosoft-teamsmicrosoft-graph-teamsuser-presence

Subscribing to presence in MS Graph API for multiple users


I am currently trying to retrieve Teams presence information via MS Graph API SDK (Beta). Everything is working smoothly when just subscribing for some users. As soon as the number of users gets larger, problems are starting. I hope someone can clarify things:

Basically I am doing it like mentioned here:

Subscription = Client.Subscriptions.Request().AddAsync(new Subscription
{
   Resource = $"/communications/presences?$filter=id in ('<guid>','<guid>',...))",
   ChangeType = "updated",
   ...
}).Result

Issue 1: Two subscriptions, one user/presence on each

After everything was working, I tried to create multiple subscriptions. In my test case two subscriptions with a single contact on each. Trying to create a second subscription does not work with the error "Operation: Create; Exception: [Status Code: Conflict; Reason: A subscription already exists. It must be deleted before a another can be made.]" I am now wondering whether I am doing something wrong or if this is a limitation (haven't found anything in the docs). I hope I am doing something wrong as the goal would be to monitor even more then the 650 users mentioned in the linked article above. The error I get:

Code: ExtensionError
Message: Operation: Create; Exception: [Status Code: Conflict; Reason: A subscripton already exists. It must be deleted before a another can be made.]
Inner error:
    AdditionalData:
    date: 2020-11-08T20:47:37
    request-id: 9d45a16b-9cac-4515-92f9-b81b36318189
    client-request-id: 9d45a16b-9cac-4515-92f9-b81b36318189
ClientRequestId: 9d45a16b-9cac-4515-92f9-b81b36318189

Issue 2: One subscription, multiple users/presences

Afterwards I tried to create a single subscription with more than my three test users, which sadly did also not work as expected:

  • 250 Users/presences
Code: ExtensionError
Message: Operation: Create; Exception: [A task was canceled.]
Inner error:
    AdditionalData:
    date: 2020-11-08T20:38:30
    request-id: c6398df3-c856-4f80-9495-0b76714d9592
    client-request-id: c6398df3-c856-4f80-9495-0b76714d9592
ClientRequestId: c6398df3-c856-4f80-9495-0b76714d9592
  • 350 Users/presences
Code: ExtensionError
Message: Operation: Create; Exception: [Status Code: BadRequest; Reason: ]
Inner error:
    AdditionalData:
    date: 2020-11-08T20:40:45
    request-id: 297f7b7d-e2d7-4ad4-8083-cc4797415287
    client-request-id: 297f7b7d-e2d7-4ad4-8083-cc4797415287
ClientRequestId: 297f7b7d-e2d7-4ad4-8083-cc4797415287
  • 650 Users/presences
Code: UnknownError
Message: The page was not displayed because the request entity is too large.
Inner error:
    AdditionalData:
    date: 2020-11-08T20:35:28
    request-id: b3580f44-dcec-4fdc-87e2-50ae92da8bd3
    client-request-id: b3580f44-dcec-4fdc-87e2-50ae92da8bd3
ClientRequestId: b3580f44-dcec-4fdc-87e2-50ae92da8bd3

Does anyone have an idea what is going wrong here? Any information would be helpful.


Solution

    • When we try to add more subscriptions then we get conflict error "A subscription already exists. It must be deleted before a another can be made", because it supports only one subscription.