Using the Site Events Viewer and the Trigger Backend functions I have created a FETCH POST request to send some XML to a third party server. The third party server is a test platform called webhook.site.
When I run the FETCH code in the front-end it reaches my webhook.site; it does not, however, arrive at the webhook.site when running in the back-end?
I have stripped the code right back to the basics - webhook is fully ‘open’, no authentication or whatever needed…
export async function getTPCatalogue(xml_parm) {
const url = 'https://webhook.site/545f7ea6-c1fa-4b9b-XXXXXXXXXXXXXXXXXX';
return fetch (url,
{
"method": "post",
"mode": "no-cors",
"headers":
{
"Content-Type": "text/xml",
"Content-Length": "2023",
"Host": "webhook.site"
},
"body": "TEST ABC"
})
.then( (httpResponse) => {
if (httpResponse.ok) {
console.log("RESPONSE OK");
return httpResponse.json();
} else {
console.log("RESPONSE NOT OK");
return Promise.reject("Fetch did not succeed");
}
})
.then( (json) => console.log(json) )
.catch(err => console.log(err));
}
Note: I’ve obscured the webhook URL
Any ideas how to progress this please?