2

I've created a layer in GeoServer. The layer is based on a SQL view and is parametrized as described in the documentation. I can access the WFS in the browser with a URL something like the below:

http://localhost:8080/geoserver/wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=cite:mylayer&maxFeatures=50&outputFormat=application%2Fjson&viewparams=myuuid:2a18bb306af24e29a8f1a40f80229749;myyear:2016

(Note the viewparams part at the end of the query string.)

But I don't see a way to set these parameters in QGIS when I'm adding the layer. I can connect successfully and find my layer in the list, but there doesn't seem to be a way to configure these parameters:

Add WFS Layer dialog

How can I set these parameters? Does the Build query functionality allow me to via some mechanism I'm not aware of?

  • You can try to create the WFS connection so that the base URL contains the view parameter http://localhost:8080/geoserver/wfs?VIEW_PARAM=my_param&. This may work if QGIS does not use the GetFeature URL that comes with the GetCapabilities. Even if it happens to work you can't make it dynamic but you must create a new connection for each VIEW_PARAM value that you will need. – user30184 Aug 27 '16 at 13:39
  • this is reported here: issues.qgis.org/issues/6354 – Lennert Oct 19 '18 at 8:34
-1

by python:

uri='http://path/wfs?SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&TYPENAME=layer&SRSNAME=EPSG:xxx&viewParams=param1:1' 
layer = QgsVectorLayer(uri, "layer_wfs_with_params", "WFS")
if not layer.isValid():
    print "Layer failed to load!"
else:
    QgsMapLayerRegistry.instance().addMapLayer(layer)
  • Welcome to GIS SE! As a new user please take the tour to learn about our focused Q&A format. A good answer should include not only what to do, but also how to do it. Please edit your answer to include an explanation about how to use your suggested solution, and what it does. – Midavalo May 24 '17 at 14:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.