Jump to content
  • 0

multi expand not possible?


David E.

Question

Posted

hi there,

trying to output the username (e.g) from a connection with odata and powershell:

(Invoke-RestMethod "https://api-us.cloud.com/monitorodata/Connections?`$expand=Session&`$top=1" -Headers $headers -Method Get).value

works well, but instead or in addition to the userId I want the username only possible through expanding another level, so:

(Invoke-RestMethod "https://api-us.cloud.com/monitorodata/Connections?`$expand=Session(`$expand=User)&`$top=1" -Headers $headers -Method Get).value # -> no error but empty output for 'User='

other tests like this are not working:

(Invoke-RestMethod "https://api-us.cloud.com/monitorodata/Connections?`$expand=Session(`$expand=Session/User)&`$top=1" -Headers $headers -Method Get).value ### -> error with URI

(Invoke-RestMethod "https://api-us.cloud.com/monitorodata/Connections?`$expand=Session(`$expand=Users)&`$top=1" -Headers $headers -Method Get).value # -> Users won't work

 

MS has different examples but I found nothing with Citrix. connections are only one example, I can reproduce it with other tables.

Someone successfully did a multi-expand in powershell and could post his code here? thanks

2 answers to this question

Recommended Posts

  • 1
Posted

The URL https://api-us.cloud.com/monitorodata/Connections?`$expand=Session(`$expand=User)&`$top=1 worked.
But the result is JSON-formatted, and by default, the depth is 2.

Please try with ConvertTo-Json -Depth 5, here is a sample

 

$response = Invoke-RestMethod 'https://api.cloud.com/monitorodata/Connections?$expand=Session($expand=User)&$top=1' -Method 'GET' -Headers $headers
$response | ConvertTo-Json -Depth 5

 

  • Thanks 1
  • 0
Posted

omg 🫣
it was just the output in the ISE that showed it as empty, as I never really checked the value. thank you very much !!

ps: even $response.value.Session.User with $response = Invoke-RestMethod 'https://api.cloud.com/monitorodata/Connections?$expand=Session($expand=User)&$top=1' -Method 'GET' -Headers $headers will work

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...