typeahead giving 0 siteId when search city which name has comma eg. Ture Sventons gata, Bromma
Sir, I am using this below api
https://api.sl.se/api2/typeahead.<FORMAT>?key=<DIN NYCKEL>&searchstring=<SÖKORD>&stationsonly=<ENDAST STATIONER>&maxresults=<MAX ANTAL SVAR>
When I search for "stockholm" then it is working Okay and giving me siteId 1080,
But when I am search a city name with comma in it, for example
Ture Sventons gata, Bromma
Ture Wennerholms torg, Hägersten
Ture Nermans gränd, Stockholm
Then it gives siteId 0
So please help me to get desired siteId with city name with comma.
Thank you.
https://api.sl.se/api2/typeahead.<FORMAT>?key=<DIN NYCKEL>&searchstring=<SÖKORD>&stationsonly=<ENDAST STATIONER>&maxresults=<MAX ANTAL SVAR>
When I search for "stockholm" then it is working Okay and giving me siteId 1080,
But when I am search a city name with comma in it, for example
Ture Sventons gata, Bromma
Ture Wennerholms torg, Hägersten
Ture Nermans gränd, Stockholm
Then it gives siteId 0
So please help me to get desired siteId with city name with comma.
Thank you.
Följ inlägget
0
följare
I tried your request and it works fine. Make sure that you URL-encode the parameter as it contains special characters.
See:
https://developer.mozilla.org/en-US/docs/Glossary/percent-encoding
https://www.w3schools.com/tags/ref_urlencode.asp
https://en.wikipedia.org/wiki/Percent-encoding
Regards,
Bert
I am search for Ture Sventons gata, Bromma
and below is my url encode string
https://api.sl.se/api2/typeahead.json?key=<key>&searchstring=Ture+Sventons+gata%2C+Bromma&stationsonly=false&maxresults=10
Please replace "key" with your key and you will find that it gives the SiteId:0
But I need genuine siteId for example 1024 or 1028
How can I get the genuine siteId.
Thanks.
https://api.sl.se/api2/TravelplannerV3_1/trip.json?key=<key>&lang=se&originExtId=0&destExtId=1080&numF=5
You can see that from previous typeahead api I got siteId:0 from Ture Sventons gata, Bromma and siteId:1080 from Stockholm.
I will not get trip results because Ture Sventons gata, Bromma gave siteId:0
Can you try with "stationsonly=true" instead of "stationsonly=false"?
Regards,
Bert
So I will use 0 in "stationonly" then it will not recognise the 0 and it will assume it as "true" because default is "true".
Then it will show only stations but not include "address" in the result. But I have to show address also in the result.
So I am looking for the solution that how to get siteId with addresses.
Thanks.