How to get specific value in web request response

74 views Asked by At

I am making a web request in powershell using $Result = Invoke-WebRequest -Uri $RequestUrl -Method $apiMethod -Body $token -ErrorAction:Stop -UseBasicParsing. It returns a response that looks like:

{
  "data" : [ {
    "deviceUid" : "02177890UHASBTE",
    "esn" : "075923846YR",
    "deviceName" : "HGY711018"
  } ],
  "metadata" : { }
}

I need to be able to access the value of the deviceName key, but I can't seem to find how to get it from the request object. I have tried $Result['data'][0]['deviceName'] but it does not work it just gives me nothing.

0

There are 0 answers