Is it possible to do a GET request to a URL that will reply with XML, then act on the data in the reply? So far it doesn’t seem that any data is saved in the $response variable to this endpoint, so I can’t even go from there. Maybe this is asking too much from webcore?
XML response handling from web request
webCoRE has special handling for JSON responses, but you should be able to use $response
as text regardless of the content type. However, the $response
variable is only populated if the service responds with a 200 OK
status. If the $httpStatusCode
variable has the value 200
after your request then there should be something usable in $response
. Granted it may not be a useful as having an XML parser at your disposal but you may be able to use string functions on the text to get what you need.
You seemed to know what you were talking about so I wrote for you. I guess these thread hijackers have a point though that writing for anyone to understand is beneficial, even if the topic is parsing XML from web requests
I wasnt the original poster - but yeah…
99% of my day job is explaining more esoteric points with non-tech people (Head of Cyber/Information Security at a fortune 500 ) so i feel the pain
Thinking through this use case, I see a bunch of potential for pulling data from ‘unconnected’ systems - I could in theory pull weather data from my PWS w/out going to Wunderground, simply by going to my own server, and sending a JSON response with HTTP200 (which it should do - potentially unless you get a redirect 301/302 in the way)
Opens up another whole thought process for me - thanks!
In all honesty, while I can’t speak for @Cozdabuch, meme is a lot more related to late night and Scotch than to what you actually wrote
This is what I’m seeing in my debug logs for the following variables:
$response = [:]
$httpStatusCode = 200
$httpStatusOk = true
Yet if I curl the same url outside webcore, I get 200 OK and XML. Other ideas?
Could you share a sample piston? A private message to me is best if the request requires any API keys or similar that you can’t post publicly.
Even just getting back data from this simple test is failing:
If I do a curl of the same URL, I get back the text from that document, which is just “test”.
Are your screenshots anonymizing the link or are you trying to make an internal call? All these actions are performed in the ST cloud which is not local. So you would need to point it at your actual IP address and port forward in your router to where you are trying to go.
@alexjhart, the issue here is that webCoRE is not able to access your internal 192.168.* IP addresses since the code runs in the cloud rather than on your local hub. Can you set up port forwarding to make your local service accessible via your public IP, or a dynamic hostname (e.g. noip.com) if your IP is not static?
Edit for future readers: Sorry, clearly this advice was wrong and local requests should work fine.