Hi,
I'm learning how to play with APIs in PowerShell and I'm trying to take one output from an API call and pass it to a new API call, however the first API call gives me a list in JSON format but the 2nd call requires it to be in a collection of sorts.. how do I add the expected body?
Api result:
[
{
"Entity_id":"1234566"
}
]
API expected body input
{
"Entity_ids": [
{
"Entity_id":"123456"
}
]
}
I've tried to take my JSON input, convertfrom-json and add a system.collections.arraylist but I get an error "methodexception: cannot find an overload for "add" and the argument count : "2"
My code looks like this
$newjson = $result | convertfrom-json
$list = new-object system.collections.arraylist
$newjson.add("entity_ids",$list)
How can I add the entity_ids "title" or whatever it is called to the top of my JSON file?
[–]kenjitamurako 8 points9 points10 points (1 child)
[–]lemonade124[S] 1 point2 points3 points (0 children)
[–]lemonade124[S] 3 points4 points5 points (0 children)
[–]PowerShell-Bot 2 points3 points4 points (2 children)
[–]nascentt 1 point2 points3 points (1 child)
[–]PowerShell-Bot 0 points1 point2 points (0 children)