Further testing, I discovered that I can open my postgrest geojson service using Python :

|myLayer= QgsVectorLayer('http://mydomain:3000/rpc/wod_geojson, 'myLayer', 'ogr') QgsProject.instance().addMapLayers([myLayer]) |


Also, testing with ogrinfo on command line, it fails with 404 error , but adding |Accept: application/json| header makes it work.
(using --config GDAL_HTTP_HEADER_FILE)

--
Christophe Damour

Le 11/02/2022 à 14:27, SIGéal a écrit :
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 :



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
_______________________________________________
Qgis-user mailing list
Qgis-user@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user

Reply via email to