<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
Hi,<br>
<br>
I have a PostgreSql stored procedure which returns a geojson feature
collection created with json_build_object function.<br>
This web service opens fine in OpenLayers, however, when I try to
open it in QGIS, with data source manager -> vector ->
protocol -> geojson :<br>
<br>
<img
src="https://user-images.githubusercontent.com/247591/153418104-5a611cb2-ad4d-4c5b-ac87-0c08be006c9e.png"
alt="https://user-images.githubusercontent.com/247591/153418104-5a611cb2-ad4d-4c5b-ac87-0c08be006c9e.png"><br>
<br>
I get the following error :<br>
<blockquote type="cite">Invalid data source: [myurl]/rpc/wod_geojson
is not a valid or recognized data source.</blockquote>
This is the query wrapped in a plpgsql function called my_geojson :<br>
<blockquote type="cite"><code>SELECT json_build_object(<br>
'type', 'FeatureCollection', 'features',<br>
json_agg(<br>
json_build_object(<br>
'type', 'Feature', 'id', id, 'geometry',<br>
ST_AsGeoJSON(ST_Transform(geometry, 4326))::json,<br>
'properties', json_build_object(<br>
'lib', lib<br>
)<br>
)<br>
)<br>
)::json my_geojson FROM (SELECT ROW_NUMBER() OVER() id, * FROM
mytable) tmp</code></blockquote>
This is the url I use to call the service:<br>
<blockquote type="cite"><code><a class="moz-txt-link-freetext" href="http://mydomain:3000/rpc/my_geojson">http://mydomain:3000/rpc/my_geojson</a></code></blockquote>
I tested a similar geojson REST service served with pg_featureserv,
and it works fine...<br>
<br>
Environment :<br>
<blockquote type="cite">
<p dir="auto">Server Environment :<br>
PostgreSQL version: 10.19<br>
PostgREST version: 9.0.0<br>
Operating system: Ubuntu 16.04</p>
<p dir="auto">Client Environment :<br>
QGIS version: 3.16.16<br>
Operating system: Windows 10</p>
</blockquote>
<br>
Thanks for any int<br>
<br>
<pre class="moz-signature" cols="72">--
Christophe Damour
</pre>
</body>
</html>