Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

POST To Assets failing due to invalid characters

Ste404
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 18, 2023

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

 

0 answers

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events