Loxone / LxCommunicator.NET

MIT License
9 stars 14 forks source link

downloading structure-File from Miniserver #2

Closed CalDymos closed 4 years ago

CalDymos commented 4 years ago

I have tried to retrieve the file "LoxAPP3.json" from the Miniserver by sending the command “data/LoxAPP3.json” to the Miniserver using WebserviceRequest and HttpRequest , unfortunately neither of them work.

How can I get the structure file from the Miniserver? Could someone give me an example of how to do this?

davidwallis commented 4 years ago

crude example of how you could pull it aside from the library..

using System;
using System.Text;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;

namespace LoxoneTestStructure
{
    class Program
    {
        static async Task Main(string[] args)
        {
            var userName = "admin";
            var passwd = "yourPassword";
            var url = "http://192.168.0.77/data/LoxAPP3.json";

            using var client = new HttpClient();

            var authToken = Encoding.ASCII.GetBytes($"{userName}:{passwd}");
            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
                    Convert.ToBase64String(authToken));

            var result = await client.GetAsync(url);

            var content = await result.Content.ReadAsStringAsync();
            Console.WriteLine(content);
        }
    }
}

Key thing is make sure you auth.

CalDymos commented 4 years ago

Thanks, that helped.