301 Error with https://api3.geo.admin.ch/rest/services/api/SearchServer

36 views
Skip to first unread message

NIS AG

unread,
Aug 12, 2022, 7:00:50 AM8/12/22
to GeoAdminCh API
Hello

Since yesterday, the calls to https://api3.geo.admin.ch/rest/services/api/SearchServer from our Webapplication are not working anymore.

We got the error:

<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>CloudFront</center>
</body>
</html>

When calling via browser, it works, because the browser can handle the 301 error.

All the release versions of our application are affected.

Regards,
Flavio
NIS AG

David Oesch

unread,
Aug 12, 2022, 7:57:08 AM8/12/22
to geoadm...@googlegroups.com
Hi Flavio 

We did a Datencenter Migration yesterday - and the following reason for your 301 results could be

The REST API had a bug in which all endpoints respond to any HTTP method like a GET. For the search endpoint /rest/services/api/SearchServer it has been fixed and now it only supports the correct methods:

GET => returns the data
HEAD => return only the headers (no payload)
OPTIONS => returns the headers for CORS (no payload)



- Versioning 
Make sure that you don’t use the depreciated versioning in your code , eg a number between api3.geo.admin.ch/ and /rest/ 

Part of the url

David
--
You received this message because you are subscribed to the Google Groups "GeoAdminCh API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/2546133a-4e84-4727-9b17-68e34ce1d10en%40googlegroups.com.

NIS AG

unread,
Aug 12, 2022, 9:16:58 AM8/12/22
to GeoAdminCh API
Hi David

Thank you for your prompt reply.

- In the code I tried to explicitly set the HTTP method GET and I still get the 301 error.


Regards,
Flavio

David...@swisstopo.ch

unread,
Aug 12, 2022, 9:34:30 AM8/12/22
to geoadm...@googlegroups.com
Can you provide the complete code snippet?

________________________________
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/2546133a-4e84-4727-9b17-68e34ce1d10en%40googlegroups.com<https://groups.google.com/d/msgid/geoadmin-api/2546133a-4e84-4727-9b17-68e34ce1d10en%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
You received this message because you are subscribed to the Google Groups "GeoAdminCh API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com<mailto:geoadmin-api...@googlegroups.com>.
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/4175b49b-2e7f-461e-86bb-5f9045a58aden%40googlegroups.com<https://groups.google.com/d/msgid/geoadmin-api/4175b49b-2e7f-461e-86bb-5f9045a58aden%40googlegroups.com?utm_medium=email&utm_source=footer>.

NIS AG

unread,
Aug 12, 2022, 9:49:59 AM8/12/22
to GeoAdminCh API
The code Snippet (Groovy/Grails) is attached.

Here the output:

DEBUG search.SwissGeocodeSearch  - parameters----: type=locations&searchText=Halde 35&sr=2056
DEBUG search.SwissGeocodeSearch  - url----: http://api3.geo.admin.ch/rest/services/api/SearchServer?type=locations&searchText=Halde%2035&sr=2056
DEBUG search.SwissGeocodeSearch  - out----: <html>

<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>CloudFront</center>
</body>
</html>
DEBUG search.SwissGeocodeSearch  - jsonResponse----: [:]

Regards,
Flavio
code-snippet.png

David...@swisstopo.ch

unread,
Aug 12, 2022, 9:59:14 AM8/12/22
to geoadm...@googlegroups.com, tic...@bgdi.ch

christoph...@swisstopo.ch

unread,
Aug 14, 2022, 10:56:03 PM8/14/22
to GeoAdminCh API
Good morning,

301 is not an error but a redirect, see also statement in the response. In that case http traffic is redirected to https since we're not accepting http traffic anymore.
If you use https in your URL you end up on the service directly and receive the desired response.

Best regards

NIS AG

unread,
Aug 16, 2022, 4:59:06 AM8/16/22
to GeoAdminCh API
Hello

In order to use https, code adjustments are required in our application. Since we have several release versions in use, this would involve considerable effort.

Is there a possibility that there will still be a transition period for http?

Regards,
Flavio
Reply all
Reply to author
Forward
0 new messages