I need to call a URL from a nodeJS function. The URL references an XML file that I’d like to store within my Glitch app. Can I store the XML file within my app and reference it with a local URL? I’ve been playing around with the Assets and public folders but can’t seem to get it to work.
Hey, I think you can just upload the XML file to assets. Once uploaded you should be able to click on it and it should present you the option to copy the URL.
Like @WenInCode I’ve been able to access an XML doc both in a public folder served statically by Express and via the Assets drawer without any difficulty - you can see it in https://glitch.com/edit/#!/anonymous-anaconda, there’s a public/api.xml file and one in Assets both of which are reachable in the browser at their expected URLs.
Can you give us a code snippet of how you’re trying to access it, or a project name that we can look at?
Oh I see. I think you are trying to get the URL from the XML file you uploaded to assets. I think you can do something similar to https://stackoverflow.com/a/41995792, where you parse the xml file to get the url in the Play section.
If I take the XML from the above URL and add it to my assets file as response.xml, and reference the full URL in my function - it doesn’t work. It can find it now, but the XML isn’t processed by Twilio (that could be a non-Glitch related error though).
That’s potentially useful from the Glitch side of things. What do you see when you host the xml file in your regular file system and server it via a public address (as opposed to in assets)?
If it’s been more than 5 minutes since your last request you project may take a little longer to respond since it will have gone to sleep, so if it appears to be timing out you could try it again and see if the result is different.
Actually you might want to try again right away. The timeout might be because your project is waking up, and if you wait too long it will go back to sleep.
You can use UptimeRobot or something similar to keep it awake all the time if that’s a continual problem.
I get an identical error if I put a typo into the URL, so it’s perhaps an issue with the https://twilio-quest-voice-example.glitch.me/response.xml parameter?
I don’t know much about Twilio; what are they trying to POST there? On closer examination I don’t think using a static url is going to allow that either.
Depending on what they require you may need to implement an endpoint they can POST to and then handle the resulting input appropriately. What’s the overall expected workflow supposed to look like?
Note that if the URL parameter is http://demo.twilio.com/docs/voice.xml, it works, but the assets/response.xml URL does not - even though they contain exactly the same XML data.
this appears when I enter an xml file: This XML file does not appear to have any style information associated with it. The document tree is shown below.
Hi, @CookieHTML! This is normal for XML files to happen when they do not have any style information associated with them. This will not cause any issue.