Unable to setup Subscription to all messages using Graph API even with Subscription.

Retallack, Mark (YU UK DOP INN) 0 Reputation points
2024-02-28T10:14:06.3266667+00:00

Hi, I have had a Subscription setup and its "connected" to the Service Principle I am using, however when I try to setup a subscription to "/me/chats/getAllMessages?model=B", I get the following error:

        APIError        Code: 402        message: None        error: MainError(additional_data={}, code='ExtensionError', details=None, inner_error=InnerError(additional_data={}, client_request_id='b3546bda-6213-4699-862b-2f2ed76e44d1', date=DateTime(2024, 2, 28, 10, 5, 59, tzinfo=Timezone('UTC')), odata_type=None, request_id='1cb606d4-827f-4619-9f64-a7daa44df961'), message='Operation: Create; Exception: [Status Code: PaymentRequired; Reason: To access this resource, the app must be associated with an Azure subscription, see https://aka.ms/teams-api-payment-requirements for details.]', target=None)

Using Graph Explorer, I can repeat this:

{
    "changeType": "created",
    "notificationUrl": "https://webhook.azurewebsites.net/api/send/myNotifyClient",
    "resource": "/me/chats/getAllMessages?model=B",
    "expirationDateTime": "2024-02-28T11:00:45.9356913Z",
    "clientState": "secretClientValue"
}

And it also generates the same issue

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,827 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sourabh Gupta 800 Reputation points Microsoft Vendor
    2024-03-02T12:51:40.78+00:00

    Hi Retallack, Mark (YU UK DOP INN),

    Thanks for reaching out.

    This API has licensing and payment requirements****. It supports both model=A and model=B query parameters. If no model is specified, evaluation mode will be used.

    Since you have mentioned model=B in your resource, it means that you are using model B payment plan for this Paid API. In order to use paid API, you have to link your app to azure subscription. You can refer to this link to get more details.

    https://learn.microsoft.com/en-us/graph/teams-licenses

    In order to use this API for free you can try evaluation mode that is by removing /model=B from your code in resource. (However, this will work until evaluation quota is reached.)

    Another option is to use other resources which are free like creating subscription to all the messages in a particular team's channel as shown in the document at following link.

    https://learn.microsoft.com/en-us/graph/teams-changenotifications-chatmessage#subscribe-to-messages-in-a-channel.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.