Forum Discussion

jonathan_roland's avatar
3 years ago

Hi everyone, I'm trying to use RestAPI with powershell

Hi everyone, I'm trying to use RestAPI with powershell to get pureone Pods informations (mediator status, and status). I have no problem to authentificate, but when I send my Api Request I'm not able to get all the informations. In items, array is empty and I don’t understand why. (I have 2 arrays in this pod) PS C:\> Invoke-RestMethod 'https://api.pure1.purestorage.com/api/1.latest/pods?names=''POD-PROD-ESX-SANhttps://api.pure1.purestorage.com/api/1.latest/pods?names=''POD-PROD-ESX-SAN'|''' -Method 'GET' -Headers $pureOneHeader | ConvertTo-Json { "total_item_count": 1, "continuation_token": , "items": [ { "id": "d2f9ca34-56b3-4efc-a18c-XxxxXXXXXxX", "name": "POD-PROD-ESX-SAN", "arrays": " ", "mediator": "purestorage", "source": , "_as_of": 1662531420000 } ] } In the rest API Guide we can find as example "arrays" : "arrays": [ { "id": "2a989a09-c851-4d52-9ec6-ab728b1c04db", "name": "example_name", "resource_type": "example_resource_type", "frozen_at": 1502729489760, "mediator_status": "online", "status": "resyncing", "fqdn": "http://example_name.dc1.example.com|example_name.dc1.example.com" } I tried as a viewer and admin (Pure1 :api rôles) Do you have and Idea ? thank you.
  • -DepthSpecifies how many levels of contained objects are included in the JSON representation. The value can be any number from `0` to `100`. The default value is `2`. `ConvertTo-Json` emits a warning if the number of levels in an input object exceeds this number.
  • jonathan.roland.ext have you tried to do the same without the powershell sdk?
  • sample curl: curl “https://api.pure1.purestorage.com/api/1.latest/pods?names=%27SEVEN10-ESX-POD1%27”
  • ```{"total_item_count":1,"continuation_token":,"items":[{"id":"035b3e79-65e1-83c1-dd25-8949723d1e1c","name":"SEVEN10-ESX-POD1","arrays":[{"id":"111fa973-b64c-44e7-a949-ce4cfb7c6d52","name":"GSE-ARRAY02","resource_type":"arrays","fqdn":"http://gse-array02.prlb.flr.c360cloud.com|gse-array02.prlb.flr.c360cloud.com","status":"online","frozen_at":,"mediator_status":"online"},{"id":"aea31e0a-04b4-420b-9fee-af39612dbb22","name":"GSE-ARRAY03","resource_type":"arrays","fqdn":"http://gse-array03.prlb.flr.c360cloud.com|gse-array03.prlb.flr.c360cloud.com","status":"online","frozen_at":,"mediator_status":"online"}],"mediator":"purestorage","source":,"_as_of":1662725820000}]}```
  • ConvertTo-Json [-InputObject] <Object> [-Depth <Int32>] [-Compress] [-EnumsAsStrings] [-AsArray] [-EscapeHandling <StringEscapeHandling>] [<CommonParameters>]