I am trying to add a cql filter to a WMS QgsRasterLayer. I was able to pull in the layer using this code:
urlWithParams="contextualWMSLegend=0&crs=EPSG:4326&IgnoreGetMapUrl=1&format=image/png&layers=locations:deerwgs&styles&url=https://localhost:8080/geoserver/wms%3FCQL_FILTER=(aid=%MULD2720112947%27)"
rlayer = QgsRasterLayer(urlWithParams, 'deerwgs', 'wms')
QgsProject.instance().addMapLayer(rlayer)
Result url: http://localhost:8080/geoserver/wms?CQL_FILTER=(aid%3D%27MULD20112947%27)&SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=44.74008059553205641,-121.8661270141599999,44.92827190130818593,-120.9374197909033626&CRS=EPSG:4326&WIDTH=1205&HEIGHT=244&LAYERS=locations:deerwgs&STYLES=&FORMAT=image/png&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi:96&TRANSPARENT=TRUE
but no image is displaying. When I copy the actual url outputted in the log into the browser the expected image does return successfully. I am not sure what my next steps are to go about debugging.