Trouble trying to register ChatGPT API with Purview

Max Segal 0 Reputation points
2025-09-29T20:13:28.3233333+00:00

Getting PowerShell errors when trying to register ChatGPT API with Purview.

Tried following the steps here but received errors...

https://techcommunity.microsoft.com/blog/microsoft-security-blog/unlocking-the-power-of-microsoft-purview-for-chatgpt-enterprise/4371239

https://learn.microsoft.com/en-us/purview/archive-chatgpt-interactions

PS C:\Windows\System32> $purviewFriendlyName = "ChatGPT-API"

PS C:\Windows\System32> $purviewObjectId = (Get-MgServicePrincipal -Filter "displayName eq '$purviewFriendlyName'").id

PS C:\Windows\System32> $msGraphServicePrincipalId = (Get-MgServicePrincipal -Filter "AppId eq '00000003-0000-0000-c000-000000000000'").id

PS C:\Windows\System32> $purviewApiServicePrincipalId = (Get-MgServicePrincipal -Filter "AppId eq '9ec59623-ce40-4dc8-a635-ed0275b5d58a'").Id

PS C:\Windows\System32> # Add Purview.ProcessConversationMessages.All (a4543e1f-6e5d-4ec9-a54a-f3b8c156163f) to the Purview resource

$bodyParam= @{

"PrincipalId"= "{$purviewObjectId}"

"ResourceId" = "{$purviewApiServicePrincipalId}"

"AppRoleId" = "{a4543e1f-6e5d-4ec9-a54a-f3b8c156163f}"

}

PS C:\Windows\System32> New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId "{$purviewObjectId}" -BodyParameter $bodyParam

New-MgServicePrincipalAppRoleAssignment_Create: Cannot convert the literal '{e1cc4563-e9c7-4f8a-bc91-385e9bf6b7fa 7ea9f787-7bc4-4ff9-80f6-da7d85f66086}' to the expected type 'Edm.Guid'.

Status: 400 (BadRequest)

ErrorCode: Request_BadRequest

Date: 2025-09-29T19:26:29

Headers:

Cache-Control : no-cache

Vary : Accept-Encoding

Strict-Transport-Security : max-age=31536000

request-id : dd26569e-3e74-44a1-81d3-2c1a21fd774c

client-request-id : a1ac040f-df92-40f4-a44a-27456df32cc4

x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"West US","Slice":"E","Ring":"4","ScaleUnit":"000","RoleInstance":"BY1PEPF00020562"}}

x-ms-resource-unit : 1

Date : Mon, 29 Sep 2025 19:26:28 GMT

Recommendation: See service error codes: https://learn.microsoft.com/graph/errors

OR after asking ChatGPT...

PS C:\Windows\System32> $purviewFriendlyName = "ChatGPT-API"

PS C:\Windows\System32> $purviewObjectId = (Get-MgServicePrincipal -Filter "displayName eq '$purviewFriendlyName'").id

PS C:\Windows\System32> $msGraphServicePrincipalId = (Get-MgServicePrincipal -Filter "AppId eq '00000003-0000-0000-c000-000000000000'").id

PS C:\Windows\System32> $purviewApiServicePrincipalId = (Get-MgServicePrincipal -Filter "AppId eq '9ec59623-ce40-4dc8-a635-ed0275b5d58a'").Id

PS C:\Windows\System32> New-MgServicePrincipalAppRoleAssignment `

-ServicePrincipalId $purviewObjectId `
-PrincipalId $purviewApiServicePrincipalId `
-ResourceId $msGraphServicePrincipalId `
-AppRoleId "df021288-bdef-4463-88db-98f22de89214"

New-MgServicePrincipalAppRoleAssignment:

Line |

2 | -ServicePrincipalId $purviewObjectId `

 |                          ~~~~~~~~~~~~~~~~

 | Cannot process argument transformation on parameter 'ServicePrincipalId'. Cannot convert value to type System.String.
Microsoft Security | Microsoft Graph
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.