Skip to content

Forbidden/UnknownError when importing hosted contents #14138

@ywhe

Description

@ywhe

Steps to reproduce

I'm following the steps in https://learn.microsoft.com/en-us/microsoftteams/platform/graph-api/import-messages/import-external-messages-to-teams#step-3-import-messages and https://learn.microsoft.com/en-us/graph/api/channel-post-messages?view=graph-rest-beta&tabs=http#example-3-import-messages-with-inline-images to import hosted content to 1:1 chat and existing channels.

following are the steps:

Start migration

$groupId="**************"
$channelId="19:**************@thread.tacv2"

#start migration
$uri = "https://graph.microsoft.com/beta/teams/$groupId/channels/$channelId/startMigration"
$body=@{
    "conversationCreationDateTime" = "2022-05-27T18:10:26.968Z"
} | ConvertTo-Json
$response = Invoke-RestMethod -Uri $uri -Headers $headers -Method Post -Body $body

Import message. Worked


$uri = "https://graph.microsoft.com/beta/teams/$groupId/channels/$channelId/messages"
$body = @{
    body = @{
        contentType = "html"
        content     = "This is an imported message."
    }
    createdDateTime = "2025-12-02T18:10:26.968Z"
    from = @{
        user = @{
            id               = "**********"
            displayName      = "John Doe"
            userIdentityType = "aadUser"
        }
    }
} | ConvertTo-Json -Depth 5

$response = Invoke-RestMethod -Uri $uri -Headers $headers -Method Post -Body $body

Import message with hosted content. Failed.

$hostedBody = @{
	body = @{
		contentType = "html"
		content = '<div><img src="../hostedContents/1/$value"></div>'
	}
	hostedContents = @(
		@{
			"@microsoft.graph.temporaryId" = "1"
			contentBytes = "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAIAQMAAAD+wSzIAAAABlBMVEX///+/v7+jQ3Y5AAAADklEQVQI12P4AIX8EAgALgAD/aNpbtEAAAAASUVORK5CYII="
			contentType = "image/png"
		}
	)
    createdDateTime = "2025-12-01T18:10:26.968Z"
    from = @{
        user = @{
            id               = "**********"
            displayName      = "John Doe"
            userIdentityType = "aadUser"
        }
    }
} | ConvertTo-Json -Depth 10

  $response = Invoke-RestMethod -Uri $uri -Headers $headers -Method Post -Body $hostedBody -ErrorAction Stop

I got the following error:

{
  "error": {
    "code": "Forbidden",
    "message": "UnknownError",
    "innerError": {
      "date": "2026-02-24T02:48:50",
      "request-id": "5b5784bc-504d-4b38-b6d6-0edce12575b5",
      "client-request-id": "5b5784bc-504d-4b38-b6d6-0edce12575b5"
    }
  }
}

Expected behavior

Message posted with no error

Actual behavior

I got an error:

{
  "error": {
    "code": "Forbidden",
    "message": "UnknownError",
    "innerError": {
      "date": "2026-02-24T02:48:50",
      "request-id": "5b5784bc-504d-4b38-b6d6-0edce12575b5",
      "client-request-id": "5b5784bc-504d-4b38-b6d6-0edce12575b5"
    }
  }
}

Error details

{
  "error": {
    "code": "Forbidden",
    "message": "UnknownError",
    "innerError": {
      "date": "2026-02-24T02:48:50",
      "request-id": "5b5784bc-504d-4b38-b6d6-0edce12575b5",
      "client-request-id": "5b5784bc-504d-4b38-b6d6-0edce12575b5"
    }
  }
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions