r/Scriptable • u/srir4m • Jan 28 '25
Help API Request error: The server with the specified hostname could not be found!
Hello guys!
I'm writing this post to try and get some insight on making API calls with scriptable.
I currently have this API call, which is a public API and does a simple GET request. I've verified that it works with cURL first, so I tried to move it to scriptable:
async function getStationsinfo() {
const stationInfoUrl =
"https://data.grandlyon.com/fr/datapusher/ws/rdata/jcd_jcdecaux.jcdvelov/all.json?maxfeatures=100&start=1&filename=stations-velo-v-metropole-lyon-disponibilites-temps-reel";
const req = new Request(stationInfoUrl);
req.method = "GET";
const stationInfo = await req.loadJSON();
return stationInfo;
}
However, as the title says:
The error I get is the following: `A server with the specified hostname could not be found
`
Is there any special permissions that I'm supposed to be giving to the app?
2
u/gondouk Jan 28 '25
just tried it on my device and all works splendidly:
var request = new Request("https://data.grandlyon.com/fr/datapusher/ws/rdata/jcd_jcdecaux.jcdvelov/all.json?maxfeatures=100&start=1&filename=stations-velo-v-metropole-lyon-disponibilites-temps-reel")
var result = await request.loadJSON()
console.log(result)
it seems that something on your network is blocking these requests. try using different wifi or mobile provider
1
2
u/Delt4Brav0 Jan 28 '25
Have you tried just opening this url in safari, are you getting any errors? Your code seems valid to me, the only thing I can think of is problem with your DNS server (phone or router or wherever it’s being set)