Hi Rodrigo,
Thanks for your response. I followed your instructions and it did not work.
Here is what I did:
curl -u admin:geoserver -XGET \
http://$host:$port/geoserver/rest/workspaces/NAIP/layergroups/$layerGroupName.json
and this was what returned from the query:
{"layerGroup":{"name":"NAIP-Imagery","mode":"SINGLE","title":"Collection of
NAIP
Imagery","workspace":{"name":"NAIP"},"publishables":{"published":[{"@type":"layer","name":"Yosemite","href":"http:\/\/localhost:8081\/geoserver\/rest\/layers\/Yosemite.json"},{"@type":"layer","name":"Sioux-Falls","href":"http:\/\/localhost:8081\/geoserver\/rest\/layers\/Sioux-Falls.json"}]},"styles":{"style":[{"name":"raster","href":"http:\/\/localhost:8081\/geoserver\/rest\/styles\/raster.json"},{"name":"raster","href":"http:\/\/localhost:8081\/geoserver\/rest\/styles\/raster.json"}]},"bounds":{"minx":-1.3352069604658E7,"maxx":-1.0748569062625762E7,"miny":4499635.009236522,"maxy":5417839.565374998,"crs":{"@class":"projected","$":"EPSG:3857"}}}}
To see what you suggested works, I manually edited the json string and added
the followings:
{"@type":"layer","name":"Sioux-Falls1","href":"http:\/\/localhost:8081\/geoserver\/rest\/layers\/Sioux-Falls1.json"}
and style:
{"name":"raster","href":"http:\/\/localhost:8081\/geoserver\/rest\/styles\/raster.json"
and the modified json looks like this:
json={"layerGroup":{"name":"NAIP-Imagery","mode":"SINGLE","title":"Collection
of NAIP
Imagery","workspace":{"name":"NAIP"},"publishables":{"published":[{"@type":"layer","name":"Yosemite","href":"http:\/\/localhost:8081\geoserver\/rest\/layers\/Yosemite.json"},{"@type":"layer","name":"Sioux-Falls","href":"http:\/\/localhost:8081\/geoserver\/rest\/layers\/Sioux-Falls.json"},{"@type":"layer","name":"Sioux-Falls1","href":"http:\/\/localhost:8081\/geoserver\/rest\/layers\/Sioux-Falls1.json"}]},"styles":{"style":[{"name":"raster","href":"http:\/\/localhost:8081\/geoserver\/rest\/styles\/raster.json"},{"name":"raster","href":"http:\/\/localhost:8081\/geoserver\/rest\/styles\/raster.json"},{"name":"raster","href":"http:\/\/localhost:8081\/geoserver\/rest\/styles\/raster.json"}]},"bounds":{"minx":-1.3352069604658E7,"maxx":-1.0748569062625762E7,"miny":4499635.009236522,"maxy":5417839.565374998,"crs":{"@class":"projected","$":"EPSG:3857"}}}}
I excuted the following curl command:
curl -v -u admin:geoserver -XPOST -H "Content-type: application/json" -d
$json
http://localhost:8081/geoserver/rest/workspaces/NAIP/layergroups/$layerGroupName.json
and got this error:
< HTTP/1.1 405 Method Not Allowed
< Allow: GET, DELETE, PUT
I then changed the "XPOST" to "XPUT" and got this error:
< HTTP/1.1 500 Internal Server Error
< Transfer-Encoding: chunked
< Server: Jetty(6.1.8)
<
* Connection #0 to host localhost left intact
* Closing connection #0
: org.codehaus.jettison.json.JSONException: Expected a ',' or '}' at
character 59 of {layerGroup:{name:NAIP-Imagery,mode:SINGLE,title:Collection
Can you or someone tell me what was wrong with what I did?
Regards,
Tam
--
View this message in context: http://osgeo-org.1560.x6.nabble.com/REST-API-for-adding-new-layer-to-existing-LayerGroup-tp5137863p5138063.html
Sent from the GeoServer - User mailing list archive at Nabble.com.