I'm working on a project using GeoServer (v2.5.2) and GeoWebcache. I want to be able to upload images to create a coverage store and its associated layers. I'm using PHP with cURL to communicate with the REST API.
The upload and the creation of the coverage store works using this code :
$curl = curl_init($service_url."workspaces/".htmlentities($workspace)."/coveragestores");
$data = '<coverageStore>
<name>'.htmlentities($name).'</name>
<type>'.htmlentities($type).'</type>
<enabled>true</enabled>
<connectionParameters>
<entry key="url">file:'.$file.'</entry>
<entry key="namespace">'.htmlentities($workspace, ENT_COMPAT).'</entry>
</connectionParameters>
</coverageStore>';
curl_setopt($curl, CURLOPT_POST, True);
curl_setopt($curl, CURLOPT_HTTPHEADER,array("Content-type: application/xml, Content-Length: ".strlen($data)));
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
curl_setopt($curl, CURLOPT_USERPWD, $auth);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$buffer = curl_exec($curl);
Now I want to create a new layer. I'm using the same code as above (only changing URL and XML parameters).
The best "documentation" I've found is this one : http://docs.geoserver.org/2.5.x/en/user/geowebcache/rest/layers.html Tried to use the GeoWebCache and GeoServer version, both return me a 404 error code.
So I've tried again using this doc : http://docs.geoserver.org/2.5.x/en/user/rest/api/layers.html But it don't say what are the POST parameters expected. The only thing I get is a 500 error code.
What am I doing wrong ? Thanks a lot.