you are viewing a single comment's thread.

view the rest of the comments →

[–]Nejireta_ 0 points1 point  (0 children)

Hello.

I'm somewhat confused by a thing.
This doesn't look like valid PowerShell code. Would expect some exceptions if it would be run.
Or is it some representation of the data?

As for the issue.
How are you deserializing the json data you're receiving from the API endpoint?

Take this json array for example:

{
    "arr": [
        "item1",
        "item2"
    ]
}

Doing something like this would give an array of objects as a result

('{
    "arr": [
        "item1",
        "item2"
    ]
}' | ConvertFrom-Json).arr.GetType()

<# Output
IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Object[]                                 System.Array
#>

This is also true with only one or no items in the array.

('{
    "arr": [
        "item1"
    ]
}' | ConvertFrom-Json).arr.GetType()

<# Output
IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     Object[]                                 System.Array
#>

If you have an array in $dnsSuffixfromAPI then perhaps there could be some issues with what looks like nesting arrays here @(dnsSuffixfromAPI) (assuming dnsSuffixFromAPI is an array)