Skip to main content
deleted 109 characters in body; edited tags
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

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

For this i have this code:

Hello friend,

I want to change the default style of the layer in Geo server using the REST API.For this i 
get this code

  curl -v -u admin:geoserver -XPUT -H "Content-type: text/xml"
  -d <layer><defaultStyle><name>polygon</name></defaultStyle></layer>"
  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

 My code is

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

<?php
 
    $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="<layer>
            <defaultStyle>
            <name>polygon</name>
            </defaultStyle>
            </layer>";
     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.
Please help me where i am wrong .

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

Hello friend,

I want to change the default style of the layer in Geo server using the REST API.For this i 
get this code

  curl -v -u admin:geoserver -XPUT -H "Content-type: text/xml"
  -d <layer><defaultStyle><name>polygon</name></defaultStyle></layer>"
  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

 My code is

<?php
 
    $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="<layer>
            <defaultStyle>
            <name>polygon</name>
            </defaultStyle>
            </layer>";
     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.
Please help me where i am wrong .

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 <layer><defaultStyle><name>polygon</name></defaultStyle></layer>"
  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

<?php
 
    $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="<layer>
            <defaultStyle>
            <name>polygon</name>
            </defaultStyle>
            </layer>";
     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.

Bumped by Community user
Source Link

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

Hello friend,

I want to change the default style of the layer in Geo server using the REST API.For this i 
get this code

  curl -v -u admin:geoserver -XPUT -H "Content-type: text/xml"
  -d <layer><defaultStyle><name>polygon</name></defaultStyle></layer>"
  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

 My code is

<?php
 
    $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="<layer>
            <defaultStyle>
            <name>polygon</name>
            </defaultStyle>
            </layer>";
     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.
Please help me where i am wrong .