Tuesday, 5 June 2018

How to set default style of layer using rest api in Geoserver


I want to change the default style of the layer in Geo server using the REST API.


For this i have this code:


  curl -v -u admin:geoserver -XPUT -H "Content-type: text/xml"
-d polygon"
http://mindcrewgis.com/geoserver/rest/layers/pymble:pymble_water

when run this command it is working fine form me. But when i convert this command in PHP then it is not working for me My PHP code for above curl command is




$url="http://mindcrewgis.com/geoserver/rest/layers/pymble:pymble_water";
$contentType = 'text/xml';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "myusername:mypassword");

$data="

polygon


";
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array("Content-Type: $contentType",
'Content-Length: '.strlen($data))
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);


$rslt = curl_exec($ch);

$info = curl_getinfo($ch);

?>

But this code is not working for me . There is something wrong in execute curl using PHP.




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...