PostXML Premature end of file
Hello, I'm currently trying to make a POSTXML request to an external server webhook which accepts XML payloads and parses them according to our requirements. I'm trying to use the ContentLoaderFunctions PostXML function but when I execute the service I get
[message: Execution error in service script [UptimeAlert] :: Premature end of file.]
My code is the following with our actual URL redacted for security reasons
// result: STRING
var IPAddress = Things["UsefulServerInfo"].ServerName;
var newUrlName = me.name.replace(" ", "%20");
var server = '<Server>'+IPAddress+'</Server>';
var site = '<Site>'+me.relatedSite+'</Site>';
var line = '<Line>'+me.relatedLines+'</Line>';
var asset = '<Asset>'+me.displayName+'</Asset>';
var technology = '<Technology>None</Technology>';
var alertname = '<AlertName>'+AlertName+'</AlertName>';
var alertdescription = '<AlertDescription>'+AlertDescription+'</AlertDescription>';
var timestamp = '<Timestamp>'+AlertTime+'</Timestamp>';
var url = '<URL>http://'+IPAddress+':9080/Thingworx/Runtime/index.html#master=PTC.SCA.SCO.AssetMonitor.MasterMashup&mashup=PTC.SCA.SCO.AssetMonitor.AssetDetailContainerMashup&defaultMashup=PTC.SCA.SCO.AssetMonitor.AssetDetail.PerformanceMonitorContainerMashup&assetName='+newUrlName+'&nestedMashup=undefined</URL>';
var stringtoxml = '<xml>' + server + site + line + asset + technology + alertname + alertdescription + timestamp + url + '</xml>';
var content = new XML(stringtoxml);
var params = {
proxyScheme: undefined /* STRING */,
headers: undefined /* JSON */,
ignoreSSLErrors: undefined /* BOOLEAN */,
useNTLM: undefined /* BOOLEAN */,
workstation: undefined /* STRING */,
useProxy: undefined /* BOOLEAN */,
withCookies: undefined /* BOOLEAN */,
proxyHost: undefined /* STRING */,
url: "https://redacted" /* STRING */,
content: content /* XML */,
timeout: undefined /* NUMBER */,
proxyPort: undefined /* INTEGER */,
password: undefined /* STRING */,
domain: undefined /* STRING */,
username: undefined /* STRING */
};
Resources["ContentLoaderFunctions"].PostXML(params);
The content ends up as an XML format below, with sensitive information again redacted, but the information is filled in as we are expecting and I have run a POST test with the same content to the same url with Postman and have no issue, I only experience an issue once I add the function call for the PostXML().
<xml> <Server>redacted</Server> <Site>redacted</Site> <Line>redacted</Line> <Asset>redacted</Asset> <Technology>Nothing</Technology> <AlertName>SomeName</AlertName> <AlertDescription>SomeDescription</AlertDescription> <Timestamp>Wed Feb 27 2019 13:41:00 GMT-0000 (UTC)</Timestamp> <URL>http://redacted:9080/Thingworx/Runtime/index.html#master=PTC.SCA.SCO.AssetMonitor.MasterMashup&mashup=PTC.SCA.SCO.AssetMonitor.AssetDetailContainerMashup&defaultMashup=PTC.SCA.SCO.AssetMonitor.AssetDetail.PerformanceMonitorContainerMashup&assetName=redacted&nestedMashup=undefined</URL> </xml>
I've tried to examine the script log but it is useless as it just repeats the same error as reported in the service execute screen with no further information showing up in debug log mode, I've also tried to observe the request in the chrome network inspector and all I see further is an error 500 from the Thingworx server. Any input on what could be causing this would be appreciated.
Thank you
Tyler

