...
- Added HTTP headers to json api.
...
How do I access stat information using the API in v1.8y3?
For older versions I could use (PowerShell based on
https://miniz.ch/2018/07/28/trouble-running-miniz/#comment-138):
$Request = '{ "id":"0", "method":"getstat" }'
$Timeout = 5
$Response = ""
$Port = 4004
Try {
$Response = Invoke-TcpRequest "localhost" -Port $Port -Request $Request -Timeout $Timeout -ErrorAction Stop
$Data = $Response | ConvertFrom-Json -ErrorAction Stop
}
Catch {
Return $null
}
All I get now is:
HTTP/1.0 200 OK
Hi UselessGuru,
Thank you for the feedback.
We added the headers to be more compatible, if the request is http then the answer should also be http.
Try this modification inside your Try {} response code:
Try {
$Response = Invoke-TcpRequest "localhost" -Port $Port -Request $Request -Timeout $Timeout -ReadToEnd 1 -ErrorAction Stop
$Data = $Response.Substring($Response.IndexOf("{")) | ConvertFrom-Json -ErrorAction Stop
}
Let us know if this solved your issue.
Cheers,
miniZ
$Response = Invoke-TcpRequest "localhost" -Port $Port -Request $Request -Timeout $Timeout -ReadToEnd 1 -ErrorAction Stop
Invoke-TcpRequest: A parameter cannot be found that matches parameter name 'ReadToEnd'.