Issue with Microsoft Teams Graph API: Null ID in hostedContents Response

Marcus Rowell 1 Reputation point
2025-04-22T07:30:28.0266667+00:00

I'm encountering an issue with the Microsoft Teams Graph API when attempting to retrieve hosted content for a Teams message. Specifically, the hostedContents endpoint returns a null ID, which leads to a "Bad Request" error when trying to access the content using that ID. Below are the details of the requests and responses.

Request 1: Retrieve hostedContents

GET /v1.0/teams/[team-id]/channels/[channel-id]/messages/[message-id]/hostedContents HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer [token]

Response:

HTTP/1.1 200 OK
{
  "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('[team-id]')/channels('[channel-id]')/messages('[message-id]')/hostedContents",
  "@odata.count": 1,
  "value": [
    {
      "id": "aWQ9LHR5cGU9MSx1cmw9aHR0cHM6Ly9b...redacted-external-url...]",
      "contentBytes": null,
      "contentType": null
    }
  ]
}

Observation: The id field decodes to id=,type=1,url=[external-url], indicating a null id value.

Request 2: Access hosted content using the provided ID

GET /v1.0/teams/[team-id]/channels/[channel-id]/messages/[message-id]/hostedContents/aWQ9LHR5cGU9MSx1cmw9aHR0cHM6Ly9b...redacted-external-url...].jpg/$value HTTP/1.1
Host: graph.microsoft.com
Authorization: Bearer [token]

Response:

HTTP/1.1 400 Bad Request

{
  "error": {
    "code": "BadRequest",
    "message": "Provided hosted content identifier is invalid.",
    "innerError": {
      "date": "2025-04-21T05:08:18",
      "request-id": "[request-id]",
      "client-request-id": "[client-request-id]"
    }
  }
}

Context

The message in question contains an external URL (e.g., a YouTube thumbnail). The hostedContents endpoint successfully returns metadata, but the id field is null, which causes the subsequent request to fail with the error "Provided hosted content identifier is invalid."

Questions

  1. Is it expected behavior for the hostedContents endpoint to return a null id (i.e., id= in the encoded response) when the content is an external URL?
  2. If a null id is expected, how should applications handle this case to retrieve the content? For example, should they fall back to the url field or skip the content?
  3. If a null id is not expected, is this a bug in the Graph API, and are there any known workarounds?

Additional Notes

  • The requests are made using a valid bearer token with appropriate permissions.
  • The issue appears specific to messages with external content, as other message types process correctly.
  • Any relevant documentation or guidance on handling hostedContents for external URLs would be greatly appreciated.

Thank you for your assistance!

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Marcus Rowell 1 Reputation point
    2025-06-26T02:09:16.5433333+00:00

    We received confirmation from Microsoft Support that this is indeed a bug. The hostedContents endpoint should not return a null ID. This was caused by an issue on Microsoft's side. A fix for the issue has been pushed to production, but any earlier messages with the malformed and illegal nullid are not being retrospectively fixed.

    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.