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 and 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 my apache tomcat installation of
geoserver-2.20.0 [JVM Version:Oracle Corporation: 1.8.0_291 (Java
HotSpot(TM) 64-Bit Server VM), Java Rendering
Engine:sun.dc.DuctusRenderingEngine] on my windows machine and the changes
to layer configuration are being reflected.

However, i am getting an 500 error for response2 with text "The CQL source
expression for attribute type12 refers to attributes unavailable in the
data source: [type12]" in my docker container with
geoserver-2.23-SNAPSHOT[JVM Version:Ubuntu: 11.0.20.1 (OpenJDK 64-Bit
Server VM), Java Rendering Engine org.marlin.pisces.MarlinRenderingEngine].

I tried to verify the postgis table and the column is alread added to the
table, and the rest-api interactions with dockerized 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.

I am unable to rectify this error. Is this my code error specific to the
version of 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

Reply via email to