Share via

Problem with api call to graph api

Einat Gelbort 5 Reputation points
2026-02-02T09:37:28.76+00:00

Hey! I’m using an Axios call to get messages from a specific channel.
I’m using this URL:

  const url = `https://graph.microsoft.com/v1.0/teams/${groupId}/channels/${channelId}/messages?$top=${amount}`;

When I run it in production, I get a 403.
In the response headers, I can see that the request reached to the following data center:

'x-ms-ags-diagnostic': '{"ServerInfo":{"DataCenter":"West US 2","Slice":"E","Ring":"4","ScaleUnit":"002","RoleInstance":"MWH0EPF000BC273"}}',

In my local environment it reached to different data center:
'x-ms-ags-diagnostic': '{"ServerInfo":{"DataCenter":"Israel Central","Slice":"E","Ring":"2","ScaleUnit":"000","RoleInstance":"TL1PEPF0000059C"}}',
and it does work

It works locally, but not in production.

What could be causing this, and how can I solve it?

Also, when I add an httpsAgent to the Axios call in production to force routing to the Israel Central datacenter, it works.

response = await axios.get(url, {
      headers: {
        Authorization: `Bearer ${token}`,
        Accept: 'application/json',
      },
      httpsAgent: new https.Agent({
        lookup: (_hostname, _options, cb) => {
          cb(null, [{ address: '20.231.132.33', family: 4 }]);
        },
      }),
    });

Thank you!

Azure API Management
Azure API Management

An Azure service that provides a hybrid, multi-cloud management platform for APIs.


1 answer

Sort by: Most helpful
  1. Sina Salam 29,846 Reputation points Volunteer Moderator
    2026-03-22T12:02:15.46+00:00

    Hello Einat Gelbort,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you are having problem with api call to graph api.

    Your production network is certainly enforcing Tenant Restrictions v2 / Universal Tenant Restrictions (or an equivalent proxy header), which blocks Graph data‑plane calls from that network, causing 403, while the same token works off‑network. Forcing traffic to a specific IP inadvertently bypassed the enforcement point, which is unsupported.

    Follow the steps below in order to fix the issue:

    1. Verify token and permissions confirm the token matches the API: delegated needs ChannelMessage.Read.All; app‑only needs ChannelMessage.Read.Group or ChannelMessage.Read.All, and app‑only calls must be made in the channel owner’s tenant. Quick check: curl -H "Authorization: Bearer $TOKEN" "https://graph.microsoft.com/v1.0/teams/{team-id}/channels/{channel-id}/messages?$top=20". See List channel messages and Resolve Graph auth errors.
    2. Align consent model Ensure the granted permission type matches the token type (delegated vs application) and that admin consent is applied where required. If you use RSC, install the app in the team and use ChannelMessage.Read.Group. See API permissions for channel messages.
    3. Check for Tenant Restrictions enforcement From the production egress, verify whether Tenant Restrictions v2 or Universal Tenant Restrictions (Global Secure Access) are applied; these can block Graph data‑plane calls and yield 403 even with a valid token. Look for the TRv2 header (e.g., sec-Restrict-Tenant-Access-Policy). See Tenant restrictions v2 and Universal tenant restrictions.
    4. Fix the policy (preferred) or isolate the workload In TRv2, allow your tenant/app (or the specific user group) so the Graph call is permitted from production; or exclude the service/principal or egress segment from Universal TR enforcement. Admins configure this in Cross‑tenant access settings and Global Secure Access. See Tenant restrictions v2 and Universal tenant restrictions.
    5. Remove IP pinning; use supported network controls Drop hardcoded IPs and rely on the Microsoft 365 endpoints service (Optimize/Allow) and supported service tags instead of static addresses; this is the recommended, durable approach for Graph connectivity. See Microsoft 365 URLs & IP ranges and Managing Microsoft 365 endpoints.
    6. Re‑test and keep Graph identifiers Re‑run the same request without IP pinning; it should now return 200. If anything fails, capture request-id and UTC Date from response headers for escalation, per Microsoft’s troubleshooting practice. See Resolve Graph authorization errors.

    I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.

    Was this answer helpful?

    0 comments No comments

Your answer

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