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.
Returned geojson looks like this :
{
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"id": 1,
"geometry": {
"type": "Point",
"coordinates": [0.0, 0.0]
},
"properties": {
"num": 1,
"lib": "bla"
}
}, {
"type": "Feature",
"id": 2,
"geometry": {
"type": "Point",
"coordinates": [1.0, 1.0]
},
"properties": {
"num": 2,
"lib": "blabla"
}
}, {
"type": "Feature",
"id": 3,
"geometry": {
"type": "Point",
"coordinates": [2.0, 2.0]
},
"properties": {
"num": 3,
"lib": "blablabla"
}
}
]
}
What am I missing ?
PostGrest response headers :
Content-Range 0-0/*
Content-Type application/geo+json
Date Wed, 09 Feb 2022 11:02:26 GMT
Server postgrest/9.0.0
Transfer-Encoding chunked
Vary Accept-Encoding
EDITED : Curiously, I can open the web service in QGIS using Python :
myLayer= QgsVectorLayer('[myurl]/rpc/wod_geojson', 'myLayer', 'ogr')
QgsProject.instance().addMapLayers([myLayer])