Hi Jody, Thanks for the response. I have tried different methods and nothing works. The only workaround I figured out is that we can set the layer's "enabled=false" and set it to true every time a column is altered or a new column is created.
However, geoserver is a part of my cloud saas platform. A user can upload vector data and the data is saved into a PostGIS table and then published to geoserver as a layer. The user can share this uploaded data/layer to multiple other users. All the shared users with edit permission can create, delete, duplicate, and rename the columns of this existing layer. Altering the layers "enabled" every time a user performs column operations might affect the performance. Please let me know if you have any suggestions. Regards On Thu, Nov 2, 2023 at 10:14 PM Jody Garnett <jody.garn...@gmail.com> wrote: > The format may of changed a bit as the ability to add CQL expressions (and > generate columns on the fly) was added in that time frame. > > There is an options to refresh the column definition from the database > table that may be more suitable than manually adding a column. > -- > Jody Garnett > > > On Nov 2, 2023 at 6:10:12 AM, Harsha Yegireddi <harsha6...@gmail.com> > wrote: > >> I am unable to update the layer configuration of a PostGIS geoserver >> layer. >> >> 1. I am adding a new column to the existing and published PostGIS >> table in the first step. >> 2. However, the geoserver automatically doesn't reflect the changes >> made to the layer. We need to manually do it through the geoserver admin >> interface using the "Reload feature type" option (image below) or automate >> it through the geoserver rest API. >> >> [image: gs_question.png] >> >> 1. The Python code for updating layer configuration through rest-API >> is given below. >> >> ``` >> >> session = requests.Session() >> session.auth = (username, password) >> layer_url_json = >> f"{geoserver_url_dL}/workspaces/{workspace_dL}/datastores/{store}/featuretypes/{layer_name}.json" >> response1 = session.get(layer_url_json) >> layer_info = response1.json()#print(layer_info) >> new_column = { >> "name": "type12", >> "type": "Boolean", # Set the data type for the new column >> "nillable":True, >> "minOccurs": 0, # Optional: Minimum occurrences >> "maxOccurs": 1 # Optional: Maximum occurrences >> } >> layer_info['featureType']['attributes']['attribute'].append(new_column) >> response2 = session.put(layer_url_json, headers={'Content-type': >> 'application/json'}, >> >> ``` >> >> The above code was working perfectly in geoserver-2.20.0 and the changes >> to layer configuration are being reflected. >> >> However, I am getting a 500 error for response2 with the text "The CQL >> source expression for attribute type12 refers to attributes unavailable in >> the data source: [type12]" in later versions of geoserver like >> geoserver-2.23, 2.24, 2.25-SNAPSHOT >> >> I tried to verify the PostGIS table and the column is already added to >> the table, and the rest-api interactions with geoserver 2.23-SNAPSHOT are >> working fine as i was able to retrieve "layer_info" and also successfully >> tested adding a new workspace using rest-api in this version. >> >> Unfortunately, I can't fix this error. Is this my code error specific to >> the version of the geoserver or is it a geoserver bug? >> >> -- >> Thanks and Regards, >> Sriharsha Yegireddi >> >> >> _______________________________________________ >> Geoserver-users mailing list >> >> Please make sure you read the following two resources before posting to >> this list: >> - Earning your support instead of buying it, but Ian Turton: >> http://www.ianturton.com/talks/foss4g.html#/ >> - The GeoServer user list posting guidelines: >> http://geoserver.org/comm/userlist-guidelines.html >> >> If you want to request a feature or an improvement, also see this: >> https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer >> >> >> Geoserver-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/geoserver-users >> >
_______________________________________________ Geoserver-users mailing list Please make sure you read the following two resources before posting to this list: - Earning your support instead of buying it, but Ian Turton: http://www.ianturton.com/talks/foss4g.html#/ - The GeoServer user list posting guidelines: http://geoserver.org/comm/userlist-guidelines.html If you want to request a feature or an improvement, also see this: https://github.com/geoserver/geoserver/wiki/Successfully-requesting-and-integrating-new-features-and-improvements-in-GeoServer Geoserver-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geoserver-users