I want to automatically (via script) add new TIF-files on the harddrive to Geoserver as a new layer. I use the REST-API for that.
In the first step I added the TIF as a coveragestore, and that step works. So I use this JSON:
{
"coverageStore":
{
"name": "test123",
"type": "GeoTIFF",
"enabled": true,
"workspace":
{
"name": "TEST"
},
"url": "file:\/\/\/data\/test123\/test123.tif"
}
}
I add that via wget and that part works:
wget --user=test '--password=test123' --header='Content-Type: application/json' --post-file=coveragestore-test123.json 'http://localhost:8080/geoserver/rest/workspaces/TEST/coveragestores'
So far it s fine. But now I want to publish that as a layer, and that doesn't work. My JSON here looks like this:
{
"layer":
{
"name": "test123",
"type": "RASTER",
"defaultStyle":
{
"name": "TEST:style123",
"workspace": "TEST"
},
"resource":
{
"@class": "coverage",
"name": "TEST:test123"
}
}
}
And I send it with this:
wget --user=test '--password=test123' --header='Content-Type: application/json' --post-file=layer-test123.json 'http://localhost:8080/geoserver/rest/layers'
It comes back with an HTTP-error 405.
What do I do wrong?