Hi there,
I have an API call that creates Objects in Assets, but it is fundamentally failing when it gets to a record like this;
first.lastname_AndroidEnterprise_8/1/2022_12:30 AM
This is running from Powershell and a PSCustomObject is made, turned into JSON and then sent over. It works fine except for messy lines like above.
The error looks like this;
Invoke-RestMethod : {"errorMessages":["AQL \"Name = first.lastname_AndroidEnterprise_10/21/2022_4:11 AM\" has invalid syntax at position 11 with error message \"mismatched input '.' expecting {, ' '}\""],"errors":{}}
I have tried a little function to try and encode the line
function FixDeviceName($IncorrectName) {
$encodedFileName = [System.Uri]::EscapeDataString($IncorrectName)
return $encodedFileName
}
but then I end up with all extra characters in the name which is going to cause other issues.
Does anyone have any ideas about what I can do to get a variable with so many special characters into a format that can be used as part of a POST to Assets.
Thanks