Hi.
Two fast questins about Powershell and Domoticz:
- How to GET JSON from domoticz when using basic-auth? (if i want to si if a lamp is on)
- How to POST JSON from domoticz when using basic-auth? (if i want to set a lamp to on)
Powershell and JSON with basic-auth?
Moderator: leecollings
-
Evelen
- Posts: 234
- Joined: Thursday 09 July 2015 12:03
- Target OS: Linux
- Domoticz version: 2.4538
- Location: Norway
- Contact:
Re: Powershell and JSON with basic-auth?
For GET, this worked:
http://stackoverflow.com/questions/2795 ... ation-on-t
Code: Select all
$user = "username"
$pass = "password"
$pair = "${user}:${pass}"
$bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
$base64 = [System.Convert]::ToBase64String($bytes)
$basicAuthValue = "Basic $base64"
$headers = @{ Authorization = $basicAuthValue }
$json_info = Invoke-WebRequest -uri "http://192.168.1.123:8080/json.htm?type=devices&rid=139" -Headers $headers
Write-Host innholdet er $Json_info.Content-
Evelen
- Posts: 234
- Joined: Thursday 09 July 2015 12:03
- Target OS: Linux
- Domoticz version: 2.4538
- Location: Norway
- Contact:
Re: Powershell and JSON with basic-auth?
Still don't know how to POST..
EDIT: Now I know.
same as GET, with GET
EDIT: Now I know.
same as GET, with GET
Who is online
Users browsing this forum: No registered users and 1 guest