Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

So, simple thing as it seems but I can't seem to make it work! I'm trying to add a raster data file (GeoTIFF) to geoserver via REST API, using curl on linux. REST API is working, since I created a new workspace using it:

curl -u admin:geoserver -v -XPOST -H 'Content-type: text/xml' \
 -d '<workspace><name>restProba</name></workspace>' \
 http://localhost:8080/geoserver/rest/workspaces

It's correctly created as shown by Geoserver's admin ui, but when I try to add a coveragestore to that workspace by executing

curl -u admin:geoserver -v -XPOST -H 'Content-type: text/xml' -d
'<coverageStore><name>int_dec</name><enabled>true</enabled>
<type>GeoTIFF</type> <url>$home/int_dec.tif</url></coverageStore>'     
"http://localhost:8080/geoserver/rest/workspaces/restProba/coveragestores?configure=all"

even though it is correctly loaded, it goes directly into the default workspace, which is not the one I want it in. Is there any way of defining which workspace i want it in? I thought it'd enough by mentioning it in the URL where I point to restProba's workspace URI but it seems to be omiting it.

Thanks for your help :-)

pd: newbie with geoserver, I've tried searching for this but either i'm not using the correct search criteria, im a fool or it's just too simple for anyone to ask that i'm even fooler for asking it :p

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

Maybe you can try this after creating the workspace:

curl -u admin:geoserver -v -XPOST -H 'Content-Type: application/xml' \
     -d '<coverageStore><name>int_dec</name><workspace>restProba</workspace>  
         <enabled>true</enabled></coverageStore>' \
         http://localhost:8080/geoserver/rest/workspaces/restProba/coveragestores

It should create a coveragestore called int_dec in the restProba workspace::

You can then reference the GeoTIFF file:

curl -u admin:geoserver -v -XPUT -H 'Content-type: text/plain' \
     -d 'file:/$home/int_dec.tif' \
      http://localhost:8080/geoserver/rest/workspaces/restProba/coveragestores/int_dec/external.geotiff?configure=first\&coverageName=int_dec

I think your problem is the missing '

Your request was:

curl -u admin:geoserver -v -XPOST -H 'Content-type: text/xml' -d
<coverageStore><name>int_dec</name><enabled>true</enabled>
<type>GeoTIFF</type> <url>$home/int_dec.tif</url></coverageStore>'     
"http://localhost:8080/geoserver/rest/workspaces/restProba/coveragestores?configure=all"

It should've been:

curl -u admin:geoserver -v -XPOST -H 'Content-type: text/xml' -d
'<coverageStore><name>int_dec</name><enabled>true</enabled>
<type>GeoTIFF</type> <url>$home/int_dec.tif</url></coverageStore>'     
"http://localhost:8080/geoserver/rest/workspaces/restProba/coveragestores?configure=all"

share|improve this answer
    
Checked it and nope, I did the request properly. Good catch tho, I'll correct the question :) (im kind of relieved it wasn't that, I'd be humiliated!) –  Mikel G. Gainza Oct 29 '12 at 13:43
1  
At least your problem will be solved ;-) Updated my answer. I hope it will work now. –  R.K. Oct 29 '12 at 14:32
    
Thanks!! That did it :) –  Mikel G. Gainza Oct 29 '12 at 14:38
    
You're welcome. :) –  R.K. Oct 29 '12 at 14:41
add comment

To add a GeoTIFF store and a layer of the same name in one step you can execute:

$ curl -v -u admin:geoserver -XPUT -H "Content-type: text/plain"
       -d "file:///path_to_directory/int_dec.tif"
       http://localhost:8080/geoserver/rest/workspaces/restProba/coveragestores/int_dec/external.geotiff

More details in the "REST configuration examples: Adding an existing shapefile".

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.