Hello mates,
I'm stucked with JSON.parse that failed to manage special character in the name of the field retrieved, I'll try to better explain :
Postman answer:
"entries": [ { "values": { "Asset ID+": "A546", "Name": "Enterprise Architecture Platform", "RTO": ">24" }, "_links": { "self": [ { "href": "https://itam/AST:Application/000000000000202%7C000000000000201%7C000000000127895%7C00000000001703" } ] } } ]
I need to print out the field Asset ID+, Name and RTO ... no problem with Name and RTO but how I can index the first field that has spaces and special char in the colum name? My code fails :
var cmdbRequest = restHost.createRequest("GET", applUrl); cmdbRequest.setHeader("Content-Type", "application/json"); cmdbRequest.setHeader("Authorization", token); try { var response = cmdbRequest.execute(); //logger.info("Status code: " + response.statusCode); if (!(response.statusCode >= 200 && response.statusCode <= 204)) { throw "HTTP " + response.statusCode + " : " + response.contentAsString; } var result = JSON.parse(response.contentAsString); for each (row in result.entries) { System.log(row.values.Name); System.log(row.values.Asset%20ID%2B); } } catch (e) { logger.error ("Could not retrieve ApplID from CMDB : " + e); throw ("Could not retrieve ApplID from CMDB : " + e); }
I tryed with :
Could someone help me with this colum? I cannot change the name of the field in the source
Cheers
you can access to that value with the square brackets, like an array
System.log(row.values["Asset ID+"])
Hello,When a property contains special characters you need to use the bracket notation, e.g. row.Values["Asset ID+"].
U saved my day! Thanks!