I know there are a number of posts on this topic but I am still a little confused.
I have setup a jsw file and coded wiz-fetch to send a request from the wix-backend to a third-party server. The request sends item-codes of a given products (usually one at a time) in the body section of the fetch. The third party server is then meant to read those details and send back a response detailing the price and availability of that product(s). However, the third-party server is configured to receive the item-details in XML and return its response in XML.
So far I am getting a 500 internal server error and I suspect the wiz-fetch is not sending my XML in XML format (as it were). The third party server cannot therefore respond.
My basic question is this; is it even possible to send XML from the Wix-backend to another server. I have read a dozen posts relating to WIX/XML but I am still not clear whether or not WIX is XML-friendly or if all transactions have to be done in JSON? Unfortunately, I can’t be sure the third-party server will accept JSON.
Thanks in advance for any help clearing this up?
Hey there!
Wix-Fetch can indeed send requests in any support HTTP format, including XML. You’d need to use the POST method to talk to your server, so you can include a body to your request. That body is the same information you might sending using cURL with the -d option, and should contain your XML string.
Here’s an example that you can use (The second one that says ‘post data to a resource’), where you can modify the Content-Type and body to match XML.
Quick question though, am I right in thinking you’re making a request to a SOAP API on that 3rd party server?
Hi… Great.!.. thanks very much for the prompt reply! I’m not entirely sure what the server at the other end does… all I have to work with is a specification sheet which simply dictates the HTML Headers and XML content for the request. Talk about flying blind! 
I will look at the example you suggest and will update this POST with my progress. I am sure there are thousands of WIX users needing to do the same.
Cheers!
Actually, I have another question please. As the fetch runs on the backend in WIX and as I don’t have access to the third-party server, how can I best view the request which is being sent/posted?
Awesome - Keep us post ed on your progress
When you have written the function in the backend, you can test your function call and view the result that comes back from the server using the Trigger Backend functions feature, a powerful tool hidden behind a small green arrow. If you’re familiar with Postman, the API testing tool, this is a utility to test your backend functions while still in the editor.

For your function, you would write the wix-fetch code that speaks to the 3rd party server within your exported function, and test it from there. You can use this tool to debug the responses you get back.
Thanks Chris… … I shall go and have a practice! Cheers
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?
I have managed to solve this by eliminating the headers one-at-a-time; my content-length of 2023 was the culprit! I now set it with greater precision!
Thanks