Post XML to website using Homeyscript

How do i send 6 lines of XML to an open local website using POST using Homeyscript?

Maybe this script gets you some ideas:

Not script, but it might come in handy:
just a few ideas using flow cards

Something like this:

const url = 'http://AA.BB.CC.DD:PP';
const xml = `\
<?xml version="1.0" encoding="UTF-8" ?>
<records>
	<record>
		<name>Alfreda Roach</name>
		<phone>(522) 884-2158</phone>
		<email>luctus.et@yahoo.ca</email>
		<address>230-6265 Aliquet, Rd.</address>
		<postalZip>361179</postalZip>
		<region>Huntingdonshire</region>
		<country>Chile</country>
	</record>
</records>
`;

await fetch(url, {
  method: 'post',
  headers: {
    'content-type' : 'text/xml',
    'content-length': xml.length,
  },
  body: xml
});
4 Likes