Skip to content

Objects set to -BodyParameter and -AdditionalProperties should be fully serialized to JSON #785

@peombwa

Description

@peombwa

Current behavior

ipRanges are not serialized to JSON when making a request.

# Request made.
$Body = @{
    "@odata.type" = "#microsoft.graph.ipNamedLocation"
    displayName = "Untrusted IP named location"
    isTrusted = $false
    ipRanges = @(
        @{ cidrAddress = "12.34.221.11/22" }
        @{ cidrAddress = "2001:0:9d38:90d6:0:0:0:0/63" })
}
New-MgIdentityConditionalAccessNamedLocation -BodyParameter $Body -Debug
# Debug log - ipRanges is not serialized to JSON.
DEBUG: POST /v1.0/identity/conditionalAccess/namedLocations HTTP/1.1
HTTP: graph.microsoft.com
Content-Type: application/json
{
  "ipRanges": [
    [ "System.Collections.DictionaryEntry" ],
    [ "System.Collections.DictionaryEntry" ]
  ],
  "isTrusted": false,
  "@odata.type": "#microsoft.graph.ipNamedLocation",
  "displayName": "Untrusted IP named location"
}

Expected behavior

Objects set to -BodyParameter or -AdditionalProperties should be fully serialized to JSON Irregardless of the depth.

$Body = @{
    "@odata.type" = "#microsoft.graph.ipNamedLocation"
    displayName = "Untrusted IP named location"
    isTrusted = $false
    ipRanges = @(
        @{ cidrAddress = "12.34.221.11/22" }
        @{ cidrAddress = "2001:0:9d38:90d6:0:0:0:0/63" })
}
New-MgIdentityConditionalAccessNamedLocation -BodyParameter $Body -Debug
# Debug log
DEBUG: POST /v1.0/identity/conditionalAccess/namedLocations HTTP/1.1
HTTP: graph.microsoft.com
Content-Type: application/json
{
  "ipRanges": [
    { "cidrAddress": "12.34.221.11/22" },
    { "cidrAddress": "2001:0:9d38:90d6:0:0:0:0/63" }
  ],
  "isTrusted": false,
  "@odata.type": "#microsoft.graph.ipNamedLocation",
  "displayName": "Untrusted IP named location"
}

AB#10414

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions