I'm trying to get content of XML file from URL to Google Sheets using Apps Script (JS)
Unfortunately URL has lots of strange redirects and I have no impact on this on server side. I need to handle it by my side in JS. In Firefox I was able to download file normally but in JS it's a challenge.
I was searched for solution for days and nothing helps. JS just can't get file content.
URL: https://www.nife.pl/getfile-woocommerce/b55a488229b69d7c4ddf2a9f1a6b5dcb.xml
I've tried those:
- Default importXML in Goolge Sheets cell like this:
=importXml("https://www.nife.pl/getfile-woocommerce/b55a488229b69d7c4ddf2a9f1a6b5dcb.xml"; "//variant")
- UrlFetchApp:
function test(){
var url = 'https://www.nife.pl/getfile-woocommerce/b55a488229b69d7c4ddf2a9f1a6b5dcb.xml';
var xml = UrlFetchApp.fetch(url,{'followRedirects': true, 'muteHttpExceptions': true}).getContentText();
var jsonV = XML_to_JSON(xml);
Logger.log(jsonV);
}
- XMLService:
var xml = XmlService.parse('https://www.nife.pl/getfile-woocommerce/b55a488229b69d7c4ddf2a9f1a6b5dcb.xml',{'followRedirects': true, 'muteHttpExceptions': true});
- tried followRedirects && muteHttpExceptions true and also false
Nothing helps.
Any idea how to get content from this XML to GoogleSheets?