I have a sql view on geoserver that is accepting ints as a parameter but as soon as I try to use a string it is throwing the exception 'invalid value for parameter id' in the logs.
This is the source of the call with a string. The string itself is '45012_33' which I add to a header in my code: &viewparams=id%3A%2245012_33%22
This always returns a corb blocked a cross-origin response exception in the console.
For reference this is the SQL View Code
SELECT rivers_geom.geom, rivers_geom.src_id
FROM water.rivers_geom
WHERE src_id = %id%
I've tried using different quotations etc. Might it be something to do with the underscore?
After searching for a few days to find an answer I've ended up using a list of integers instead and decided to use a different value for the parameter.
However I did come across a user who mentioned that to use strings you have to add quotes to the sql query like so:
SELECT rivers_geom.geom, rivers_geom.src_id
FROM water.rivers_geom
WHERE src_id = '%id%'
Notice the ' ' around the parameter:
'%id%'
I managed to get this to work in the end. To make the GET call to geoserver I added the value to the header like so
viewparam=id:45012_7
Geoserver then adds the quotations in to make it a string.