Hi,
I have worked with geoserver rest api and it is great, The only problem is
that I have no idea how to post content of my sld using api, I have this
code

    public void AddNewStyle(String styledata, string workspace)
            {
                String requestUrl = RestServiceUrl + "/workspaces/" +
workspace + "/styles";
    
                String status = String.Empty;
    
                object payload = styledata;
    
                try
                {
                    status = SendRestRequest(requestUrl, RequestMethod.Post,
typeof(WorkspaceRequest), ref payload, ContentType.Html, AcceptType.Json);
                }



                catch (Exception ex)
                {
                    throw new Exception("Adding datastores failed.", ex);
                }
            }

this code works fine with other requests. the only problem is I dont know
what to send as styledata. I have set styledata as 

    <?xml version="1.0" encoding="UTF-8"?>
    <StyledLayerDescriptor version="1.0.0"
xmlns="http://www.opengis.net/sld"; xmlns:ogc="http://www.opengis.net/ogc";
      xmlns:xlink="http://www.w3.org/1999/xlink";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:gml="http://www.opengis.net/gml";
      xsi:schemaLocation="http://www.opengis.net/sld
http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd";>
      <NamedLayer>
        <Name>Baft Farsode</Name>
        <UserStyle>
          <Name>BaftFarsoode</Name>
          <Title>بافت فرسوده</Title>
          <Abstract>BaftFarsoode area</Abstract>
          <FeatureTypeStyle>
          <FeatureTypeName>Feature</FeatureTypeName>
            <Rule>
              <Title>بافت فرسوده</Title>
              <ogc:Filter>
                <ogc:PropertyIsEqualTo>
                 <ogc:PropertyName>Farsoode</ogc:PropertyName>
                 <ogc:Literal>1</ogc:Literal>
                </ogc:PropertyIsEqualTo>
              </ogc:Filter>
              <PolygonSymbolizer>
                 <Fill>
                    
                    <CssParameter name="fill">#4DFF4D</CssParameter>
                    <CssParameter name="fill-opacity">0.7</CssParameter>
                 </Fill>     
              </PolygonSymbolizer>
            </Rule>
                 <Rule>
              <Title>بدون داده</Title>
              <ogc:Filter>
                
                <ogc:PropertyIsNull>
                 <ogc:PropertyName>Farsoode</ogc:PropertyName>
                 
                </ogc:PropertyIsNull>
              </ogc:Filter>
              <PolygonSymbolizer>
                 <Fill>
                    
                    <CssParameter name="fill">#ffffff</CssParameter>
                    <CssParameter name="fill-opacity">0.7</CssParameter>
                 </Fill>     
              </PolygonSymbolizer>
            </Rule>
                
            <Rule>
              <Title>غیر فرسوده</Title>
              <ogc:Filter>
                <ogc:PropertyIsEqualTo>
                        <ogc:PropertyName>Farsoode</ogc:PropertyName>
                        <ogc:Literal>0</ogc:Literal>
                </ogc:PropertyIsEqualTo>
              </ogc:Filter>
              <PolygonSymbolizer>
                 <Fill>
                    
                    <CssParameter name="fill">#FF4D4D</CssParameter>
                    <CssParameter name="fill-opacity">0.7</CssParameter>
                 </Fill>     
              </PolygonSymbolizer>
            </Rule>
    
            <Rule>
              <Title>مرز املاک</Title>
              <LineSymbolizer>
                <Stroke>
                  <CssParameter name="stroke-width">0.2</CssParameter>
                </Stroke>
              </LineSymbolizer>
            </Rule>
         </FeatureTypeStyle>
        </UserStyle>
        </NamedLayer>
    </StyledLayerDescriptor>


but it gives error, I think there must be another way to add style data as
raw xml using rest api. 
Can some one helps me about this?thanks

here is an example but it uploads sld file into geoserver. I want to send
data as a raw string not by uploading.
http://docs.geoserver.org/latest/en/user/rest/examples/curl.html#creating-a-layer-style-sld-package



--
View this message in context: 
http://osgeo-org.1560.x6.nabble.com/Add-new-raw-style-using-REST-api-tp5298714.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/xeonphi
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to