Escaping equals sign with New-UDEndpoint

I’m getting the error ‘Cannot bind argument to parameter ‘InputObject’ because it is null’ if I send a value to New-UDEndpoint that contains an equals sign.

I’m wondering if I can escape this character?

This is a lightly modified version of Adam’s Gist

$apiport = 10001

$Cache:Users = @(
[PSCustomObject]@{ Name = “Adam”; DN = “OU=Admins,DC=company,DC=local”}
[PSCustomObject]@{ Name = “Frank”; DN = “OU=Employees,DC=company,DC=local”}
[PSCustomObject]@{ Name = “Bill”; DN = “OU=Employees,DC=company,DC=local”}
)

$Endpoints = @()
$Endpoints += New-UDEndpoint -Url “user” -Method Get -Endpoint {
$Cache:Users | ConvertTo-Json
}
$Endpoints += New-UDEndpoint -Url “user” -Method Post -Endpoint {
param($Body)

$Cache:Users +=  $Body | ConvertFrom-Json 

}

Start-UDRestApi -Port $apiPort -Endpoint $Endpoints -Name “Test”

Name Port Running


Test 10001 True

Invoke-RestMethod -Uri http://localhost:10001/api/user

Name DN


Adam OU=Admins,DC=company,DC=local
Frank OU=Employees,DC=company,DC=local
Bill OU=Employees,DC=company,DC=local

Invoke-RestMethod -Uri http://localhost:10001/api/user -Method POST -Body ([PSCustomObject]@{ Name = “Stefan”; DN = “OU=Employees,DC=company,DC=local”} | ConvertTo-Json)

@{message=Cannot bind argument to parameter ‘InputObject’ because it is null.; location=; type=error; id=; refreshInterval=0; autoRefresh=False; hasCallback=False}

But if I remove the ‘=’ sign and replace with a coon for example there are no issues . . .

Invoke-RestMethod -Uri http://localhost:10001/api/user -Method POST -Body ([PSCustomObject]@{ Name = “Stefan”; DN = “OU:Employees,DC:company,DC:local”} | ConvertTo-Json)

Invoke-RestMethod -Uri http://localhost:10001/api/user

Name DN


Adam OU=Admins,DC=company,DC=local
Frank OU=Employees,DC=company,DC=local
Bill OU=Employees,DC=company,DC=local
Stefan OU:Employees,DC:company,DC:local