C# Allumage d'une position

using Newtonsoft.Json;
using System;
using System.IO;
using System.Net;
using System.Text;

namespace SwitchOnPosition
{
    class Program
    {
        class Datas
        {
            public string Position { get; set; }
            public string Color { get; set; }
            public int Effect { get; set; }
        }

        static void Main(string[] args)
        {
            try
            {
                string positionName = "POSITION01";
                string yourUserName = "admin";
                string yourPassword = "yourpassword";
                string yourServer = "xxx.pblsrv.com";

                Datas dataObj = new Datas();
                dataObj.Position = positionName;
                dataObj.Color = "#FFFF00"; 
                dataObj.Effect = 1; // Blinking

                string jsonData = JsonConvert.SerializeObject(dataObj);

                string authInfo = yourUserName + ":" + yourPassword;
                authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
                var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://" + yourServer + ":1337/PBL_SwitchOnPosition/");
                httpWebRequest.Accept = "application/json";
                httpWebRequest.ContentType = "application/json; charset=utf-8";
                httpWebRequest.Method = "POST";
                httpWebRequest.Headers.Add("Authorization", "Basic " + authInfo);

                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    streamWriter.Write(jsonData);
                    streamWriter.Flush();
                    streamWriter.Close();
                }

                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                    Console.WriteLine(result);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}

C# Extinction d'une position

using Newtonsoft.Json;
using System;
using System.IO;
using System.Net;
using System.Text;

namespace SwitchOffPosition
{
    class Program
    {
        class Datas
        {
            public string Position { get; set; }
            public string Color { get; set; }
        }

        static void Main(string[] args)
        {
            try
            {
                string positionName = "POSITION01";
                string yourUserName = "admin";
                string yourPassword = "yourpassword";
                string yourServer = "xxx.pblsrv.com";

                Datas dataObj = new Datas();
                dataObj.Position = positionName;
                dataObj.Color = "#FFFF00"; 

                string jsonData = JsonConvert.SerializeObject(dataObj);

                string authInfo = yourUserName + ":" + yourPassword;
                authInfo = Convert.ToBase64String(Encoding.Default.GetBytes(authInfo));
                var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://" + yourServer + ":1337/PBL_SwitchOffPosition/");
                httpWebRequest.Accept = "application/json";
                httpWebRequest.ContentType = "application/json; charset=utf-8";
                httpWebRequest.Method = "POST";
                httpWebRequest.Headers.Add("Authorization", "Basic " + authInfo);

                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    streamWriter.Write(jsonData);
                    streamWriter.Flush();
                    streamWriter.Close();
                }

                var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    var result = streamReader.ReadToEnd();
                    Console.WriteLine(result);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}