I managed to return the content of invoke-webrequest in the form of string but now I am out of idea to access the individual value inside since it is string value.
This is a snippet of the returned string, I omit some part of the value
{
"odata.metadata":"https://wdzbomfg1.com/api/odata/v3/$metadata#report_description","odata.count":"18
80","value":[
{
"ActivityInstanceDestinationID":"20","ActivityName":"Task","ActivityInstan
ceID":"18","ProcessInstanceID":"1223","Destination":"a2\\","StartDate
":"2021-05-10T18:47:01","FinishDate":"1900-01-01T00:00:00","Status":"Active","Du
ration":"0","ProcessName":"ReviewSub","ProcessFolder":"Work","Fol
io":"","ExpectedDuration":"0","ActivityID":"","Final_Acti
on":null,"ActivityDisplayName":"Task"
}
],"odata.nextLink":"https://wdzbomfg1.com/api/odata/v3/$metadata#report_description?$filter=StartDate%20ge%20d
atetime'2021-05-10T13:40:08'&$skip=1000"
}
I already tried to convert it to json but it convert everything into a single value inside odata.metadata . All I want is to be able to access it like an array for example $var.odata.count will output 1880.
$Json = @'
{
"odata.metadata":"https://wdzbomfg1.com/api/odata/v3/$metadata#report_description","odata.count":"18
80","value":[
{
"ActivityInstanceDestinationID":"20","ActivityName":"Task","ActivityInstan
ceID":"18","ProcessInstanceID":"1223","Destination":"a2\\","StartDate
":"2021-05-10T18:47:01","FinishDate":"1900-01-01T00:00:00","Status":"Active","Du
ration":"0","ProcessName":"ReviewSub","ProcessFolder":"Work","Fol
io":"","ExpectedDuration":"0","ActivityID":"","Final_Acti
on":null,"ActivityDisplayName":"Task"
}
],"odata.nextLink":"https://wdzbomfg1.com/api/odata/v3/$metadata#report_description?$filter=StartDate%20ge%20d
atetime'2021-05-10T13:40:08'&$skip=1000"
}
'@
$Object = ConvertFrom-Json $Json
$Object.'odata.count'
18
80
ConvertFrom-Json
deserializes the $Json
string where the 'odata.count'
contains the requested value.
Note that in your example the value 1880
is split by a newline with outputs the value 18
and 80
on different lines.