I have not been able to get the most features to work
I get an error message:
StatusCode : 200 StatusDescription : OK Content : { "stat": "fail", "code": 401, "message": "Unauthorized" }
I can check firmware but everything else is ‘Unauthorized’
Login response:
StatusCode : 200 StatusDescription : OK Content : { "stat": "ok", "response": { "permission": { "GET": 1, "POST": 1 } } }
Firmware check:StatusCode : 200 StatusDescription : OK Content : { "stat": "ok", "response": { "2": { "version": "8.0.0 build 3455", "bootable": true, "inUse": true }, "order": [ 2 ] } }
Powershell script:
add-type @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
public class TrustAllCertsPolicy : ICertificatePolicy {
public bool CheckValidationResult(
ServicePoint srvPoint, X509Certificate certificate,
WebRequest request, int certificateProblem) {
return true;
}
}
"@
[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$creds = @{
“username”=“xxx”
“password”=“xxx”
} | ConvertTo-Json
$deviceUrl = “https://xxx”
Invoke-WebRequest “$deviceUrl/api/login” -Method POST -Body $creds -SessionVariable webSession -ContentType “application/json” #Working
Invoke-WebRequest “$deviceUrl/api/info.firmware” -WebSession $websession -Method GET #Working
Invoke-WebRequest “$deviceUrl/api/auth.client” -WebSession $websession -Method GET #Not working