We use the request below, and it works for us.

URL:  %HOST%/rest/layers/%LYR%

Body:  <layer><defaultStyle><name>%STYLE%</name></defaultStyle></layer>

On Mon, Feb 27, 2017 at 1:24 AM, David Alda Fernandez de Lezea <
da...@hazi.eus> wrote:

> Hi,
>
> I'm developing a small program to automatically populate some satellite
> images via REST. I successfully populate them , but now I'm trying to set a
> specific style for one type of layer I'm populating but I'm getting some
> errors 405 and nothing else. I want that style to be the default style.
> Here is my code:
>
>         WebRequest newrequest = WebRequest.Create("http://
> mydomain.com/rest/layers/TELEDETEKZIOA:" + imagen.layerName);
>                 newrequest.ContentType = "text/xml";
>                 newrequest.Method = "POST";
>                 newrequest.Credentials = new NetworkCredential(userName,
> password);
>                 xml = "<layer><defaultStyle><name>
> ImagenesSateliteNDVI</name></defaultStyle><enabled>true</
> enabled></layer>";
>
>                 buffer = Encoding.GetEncoding("UTF-8").GetBytes(xml);
>                 Stream newrequestStream = newrequest.GetRequestStream();
>                 newrequestStream.Write(buffer, 0, buffer.Length);
>                 newrequestStream.Close();
>
>                 response = newrequest.GetResponse();
>                 Console.Write("Response from GeoServer: " + response);
>
> Any Ideas??
>
> Thanks in advance.
>
> Regards,
>
> Agur bero bat,
>
>
> David Alda Fernández de Lezea
> Área de Sistemas de Información Geográfica, Planificación Territorial y
> Forestal Informazio Geografikoen Sistemak, Lurralde eta Baso Antolaketaren
> Arloa.
> da...@hazi.eus | www.hazi.eus
> T 945 003 240 - M 627 923 170 - F 945 003 290
> Hazi | Granja Modelo de Arkaute s/n | 01192 Arkaute - Araba
>
> *********************  LEGE OHARRA   *******************   AVISOLEGAL
> *******************   DISCLAIMER   *****************************
> Mezu hau pertsonala eta isilpekoa da eta baimenik gabeko erabilera
> debekatua dago legalki. Jasotzailea ez bazara ezabatu mezua, bidali eta
> kontserbatu gabe.
> Este mensaje es personal y confidencial y su uso no autorizado está
> prohibido legalmente. Si usted no es el destinatario, proceda a borrarlo,
> sin reenviarlo ni conservarlo.
> This message is personal and confidential, unauthorised use is legally
> prohibited. If you are not the intended recipient, delete it without
> resending or backing it.
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, SlashDot.org! http://sdm.link/slashdot
> _______________________________________________
> Geoserver-users mailing list
> Geoserver-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to