Hallo Zusammen,
ich mache folgendes:
$jsonLog = @" [{"cmd":"Login","action":0,"param":{"User":{"userName":"xxxx","password":"xxxx"}}}]"@ $params = @{ Uri = 'http://192.xxx.xxx.xx/cgi-bin/api.cgi?cmd=Login&token=null' Method = 'POST' Body = $jsonLog ContentType = 'application/json' } Invoke-RestMethod @params Invoke-WebRequest @params
Ausgabe
Invoke-RestMethod @params:
cmd code value
--- ---- -----
Login 0 @{Token=}
--------------------------
Invoke-WebRequest @paramsStatusCode : 200
StatusDescription : OK
Content : [
{
"cmd" : "Login",
"code" : 0,
"value" : {
"Token" : {
"leaseTime" : 3600,
"name" : "54de260b4820bfb"
}
}
}
]
RawContent : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Connection: keep-alive
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Content-Type: text/html
Date: Sun, ...
Forms : {}
Headers : {[Transfer-Encoding, chunked], [Connection, keep-alive], [X-Frame-Options, SAMEORIGIN], [X-XSS-Protection, 1;
mode=block]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml : System.__ComObject
RawContentLength : 184
Ich möchte gerne an "name" : "54de260b4820bfb" rankommen. Da der Content json ist musste doch
Invoke-RestMethod @params gehen. aber wie?
Danke