[QGIS-Developer] Can't open postgrest geojson service

SIGéal sigeal at sigeal.com
Fri Feb 11 05:27:39 PST 2022


Hi,

I have a PostgreSql stored procedure which returns a geojson feature 
collection created with json_build_object function.
This web service opens fine in OpenLayers, however, when I try to open 
it in QGIS, with data source manager -> vector -> protocol -> geojson :

https://user-images.githubusercontent.com/247591/153418104-5a611cb2-ad4d-4c5b-ac87-0c08be006c9e.png

I get the following error :
> Invalid data source: [myurl]/rpc/wod_geojson is not a valid or 
> recognized data source.
This is the query wrapped in a plpgsql function called my_geojson :
> |SELECT json_build_object(
>     'type', 'FeatureCollection', 'features',
>     json_agg(
>         json_build_object(
>             'type', 'Feature', 'id', id, 'geometry',
>             ST_AsGeoJSON(ST_Transform(geometry, 4326))::json,
>             'properties', json_build_object(
>                 'lib', lib
>             )
>         )
>     )
> )::json my_geojson FROM (SELECT ROW_NUMBER() OVER() id, * FROM 
> mytable) tmp|
This is the url I use to call the service:
> |http://mydomain:3000/rpc/my_geojson|
I tested a similar geojson REST service served with pg_featureserv, and 
it works fine...

Environment :
>
> Server Environment :
> PostgreSQL version: 10.19
> PostgREST version: 9.0.0
> Operating system: Ubuntu 16.04
>
> Client Environment :
> QGIS version: 3.16.16
> Operating system: Windows 10
>

Thanks for any int

-- 
Christophe Damour
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20220211/43eb4dd8/attachment.html>


More information about the QGIS-Developer mailing list