Description
Describe the bug
I suspect this is related to issue #3154 but i dont see any reference to the New-MgApplicationOwnerByRef function there.
Attempting to assign application owners using powershell using a script that was previously working. In version 2.26.0 it is failing with an error of
Invalid URL format specified in payload. Status: 400 (BadRequest)
Expected behavior
specified owner should be assigned to the app
How to reproduce
$appId = '<app id for the app in question>'
$application = Get-MgApplication -All -Filter "AppId eq '$appId'"
$ownerId = (Get-MgUser -UserId 'myUser@myDomain.com').Id
$params = @{ "@odata.id" = "https://graph.microsoft.com/v1.0/directoryObjects/${ownerId}"}
New-MgApplicationOwnerByRef -ApplicationId $application.id -BodyParameter $params
SDK Version
2.26.0
Latest version known to work for scenario above?
2.18.0
Known Workarounds
No response
Debug output
Click to expand log
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
POST
Absolute Uri:
https://graph.microsoft.com/v1.0/applications/648f283c-9f86-xxxx-xxxx-4ce67d658b33/owners/$ref
Headers:
FeatureFlag : 00000003
Cache-Control : no-store, no-cache
User-Agent : Mozilla/5.0,(Macintosh; Darwin 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan 2 20:22:58 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8132; en-US),PowerShell/2025.0.0
SdkVersion : graph-powershell/2.26.0
client-request-id : 31a75c6f-d787-xxxx-xxxx-efdbe7fb1acc
Accept-Encoding : gzip,deflate,b
Body:
{
"@odata.id": "https:graph.microsoft.comv1.0directoryObjectsebbafa77-ee4f-xxxx-xxxx-aeb4c780c409"
}
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
BadRequest
Headers:
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : d6c696c0-6e3c-xxxx-xxxx-ae419aeffee9
client-request-id : 31a75c6f-d787-xxxx-xxxx-efdbe7fb1acc
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"East US","Slice":"E","Ring":"5","ScaleUnit":"000","RoleInstance":"BL6PEPF0001F60B"}}
Date : Mon, 24 Feb 2025 19:29:09 GM
Body:
{
"error": {
"code": "BadRequest",
"message": "Invalid URL format specified in payload.",
"innerError": {
"date": "2025-02-24T19:29:10",
"request-id": "d6c696c0-6e3c-xxxx-xxxx-ae419aeffee9",
"client-request-id": "31a75c6f-d787-xxxx-xxxx-efdbe7fb1acc"
}
}
}
New-MgApplicationOwnerByRef_Create: Invalid URL format specified in payload.
Status: 400 (BadRequest)
ErrorCode: BadRequest
Date: 2025-02-24T19:29:10
Headers:
Vary : Accept-Encoding
Strict-Transport-Security : max-age=31536000
request-id : d6c696c0-6e3c-xxxx-xxxx-ae419aeffee9
client-request-id : 31a75c6f-d787-xxxx-xxxx-efdbe7fb1acc
x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"East US","Slice":"E","Ring":"5","ScaleUnit":"000","RoleInstance":"BL6PEPF0001F60B"}}
Date : Mon, 24 Feb 2025 19:29:09 GM
Recommendation: See service error codes: https://learn.microsoft.com/graph/errors
DEBUG: [CmdletEndProcessing]: - New-MgApplicationOwnerByRef end processing.
Configuration
Name Value
---- -----
PSVersion 7.5.0
PSEdition Core
GitCommitId 7.5.0
OS Darwin 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan 2 20:22:58 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T8132
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Other information
Debug output indicates that the forward slashes are all being stripped from my body parameter, I suspect this is causing the problem. I confirmed with a coworker running 2.18.0 that his debug output does not have the slashes stripped from the body parameter and his works correctly.