I am trying to implement a ReST request in PowerShell. Below is my $response in PowerShell.
@type : bundleObject
id : ZZZZZZ160000000000RU
orgId : 000007
name : xxxxxxxxxx
description : Bundle being used for QA.
createTime : 2015-04-24T15:13:24.000Z
updateTime : 2015-04-24T15:13:24.000Z
createdBy : [email protected]
updatedBy : [email protected]
lastVersion : 1.0
paid : False
accessType : PUBLIC
objects : {@{@type=bundleRefObject; objectTypeCode=17;
objectId=ZZZZZZ17000000000003;
objectName=Mapping_01; objectDescription=;
objectUpdateTime=2015-04-24T15:05:41.000Z},
@{@type=bundleRefObject; objectTypeCode=17;
objectId=ZZZZZZ17000000000004;
objectName=Mapping_02; objectDescription=;
objectUpdateTime=2015-04-24T15:09:28.000Z},
@{@type=bundleRefObject; objectTypeCode=17;
objectId=ZZZZZZ17000000000005;
objectName=Mapping_03; objectDescription=;
objectUpdateTime=2015-04-24T15:11:59.000Z}}
externalId : CYIhYNVCSdC6J17N-LyA6A
In the objects section, there are 3 object ids. I need to copy these ids & names in a list, for later use. I have successfully fetched the objects part using
$responseobject = $response.objects
However, I am unsure how I can fetch the object name & object ids and save in a list. Should I use a PSCustomObject here?
--------------------------Updated
One more query here. I added the values to a hashmap with
$response_connection_hashmap = $response_connection|foreach {
@{ $_.name = $_.id }
}
However, while fetching values with key
$response_connection_hashmap.Item('Key_1')
I am getting error as
Exception getting "Item": "Cannot convert argument "index", with value: "Key_1", for "get_Item" to type "System.Int32": "Cannot convert value "Key_1" to type "System.Int32". Error: "Input string was not in a correctformat.
am I missing something else?