CiscoDevNet / awesome-xapi

A curated list of developer resources to integrate with Webex Devices
http://cs.co/roomdevices
Other
63 stars 18 forks source link

add examples in PowerShell #44

Open ObjectIsAdvantag opened 4 years ago

ObjectIsAdvantag commented 4 years ago

see post in xAPI devs space


I'm running into a bit of a roadblock deploying Macros to the endpoints via the putxml API. I'm using PowerShell to read in the contents of a txt file that contains the JS code using Get-Content. When I insert this into the XML body <Command><Macros><Macro><Save><Name>Testing</Name><Overwrite>True</Overwrite><body>$macroBody</body></Save></Macro></Macros></Command> the result is a giant blob of text. When I POST this it ends up as a single line of text on the endpoint... Which is a problem when you have comments in your JavaScript. Anybody know how I can maintain my line breaks in the import file? Probably a PowerShell thing I need to figure out...

Blah... Yeah, it's a PowerShell thing. Instead of deleting my above post, I will include the solution in case it helps anyone else... When you use Get-Content it will strip carriage returns. Instead, use Get-Content -Raw and the carriage returns will be preserved.
$response | ConvertTo-Json