2

I have problem with adding raster layer to geoserver automatically. I need, that geoserver add layer without person job, only script action and i saw that it may be done with cURL REST API but, i can't do it. In general, I have some GeoTIFF files and i want to published them at geoserver through the terminal. I do how wrote DaveParillo. I can add workspace,

 curl -u admin:geoserver -v -XPOST -H 'Content-type: text/xml' -d '<workspaces><name>geotiff</name></workspaces>' http://192.168.255.197:8080/geoserver/rest/workspaces

answer

* Hostname was NOT found in DNS cache
*   Trying 192.168.255.197...
* Connected to 192.168.255.197 (192.168.255.197) port 8080 (#0)
* Server auth using Basic with user 'admin'
> POST /geoserver/rest/workspaces HTTP/1.1
> Authorization: Basic YWRtaW46Z2Vvc2VydmVy
> User-Agent: curl/7.35.0
> Host: 192.168.255.197:8080
> Accept: */*
> Content-type: text/xml
> Content-Length: 43
>
* upload completely sent off: 43 out of 43 bytes
< HTTP/1.1 201 Created
< Date: Thu, 10 Dec 2015 14:15:53 GMT
< Location: http://192.168.255.197:8080/geoserver/rest/workspaces/geotiff
* Server Noelios-Restlet-Engine/1.0..8 is not blacklisted
< Server: Noelios-Restlet-Engine/1.0..8
< Transfer-Encoding: chunked
<
* Connection #0 to host 192.168.255.197 left intact

but when i try add store i touch this error:

curl -u admin:geoserver -v -XPOST -H 'Content-type: text/xml' -d '<coverageStore><name>fff</name><enabled>true</enabled><type>GeoTIFF</type><url>/opt/tomcat/webapps/geoserver/data/avhrr_locale1e2.tif</url></coverageStore>' "http://192.168.255.197:8080/geoserver/rest/workspaces/geotiff/coveragestores?configure=all"

answer:

* Hostname was NOT found in DNS cache
*   Trying 192.168.255.197...
* Connected to 192.168.255.197 (192.168.255.197) port 8080 (#0)
* Server auth using Basic with user 'admin'
> POST /geoserver/rest/workspaces/geotiff/coveragestores?configure=all     HTTP/1.1
> Authorization: Basic YWRtaW46Z2Vvc2VydmVy
> User-Agent: curl/7.35.0
> Host: 192.168.255.197:8080
> Accept: */*
> Content-type: text/xml
> Content-Length: 155
>
* upload completely sent off: 155 out of 155 bytes
< HTTP/1.1 500 Internal Server Error
* Server Apache-Coyote/1.1 is not blacklisted
< Server: Apache-Coyote/1.1
< Content-Type: text/plain
< Transfer-Encoding: chunked
< Date: Thu, 10 Dec 2015 14:16:14 GMT
< Connection: close
<
* Closing connection 0
:Store must be part of a workspace

Geoserver log same error:

2015-12-10 17:15:53,801 INFO [catalog.rest] - POST workspace geotiff
2015-12-10 17:16:14,687 INFO [org.geoserver] - Loaded store 'fff',    enabled
2015-12-10 17:16:14,688 ERROR [geoserver.rest] - :Store must be part of a   workspace
2015-12-10 17:16:14,688 ERROR [geoserver.rest] - 
org.geoserver.rest.RestletException: java.lang.IllegalArgumentException:   Store must be part of a workspace

What's wrong?

Geoserver v.2.8.1.

Ian Turton
  • 81,417
  • 6
  • 84
  • 185
Warden
  • 33
  • 2
  • 10

1 Answers1

3

You need to add the workspace name when creating coverage store. In your case XML will look like this:

<coverageStore>
  <name>fff</name>
  <enabled>true</enabled>
  <type>GeoTIFF</type>
  <workspace>geotiff</workspace>
  <url>/opt/tomcat/webapps/geoserver/data/avhrr_locale1e2.tif</url>
</coverageStore>