Closed sovapatr closed 3 years ago
/v2/device/{deviceUid}/quickjob requires that the variables field be an array. If you pipe a single item array to ConvertTo-Json the returned json is no longer an array.
PS > $vars = @() + @{name = "timeout";value = 5} PS > $vars | ConvertTo-Json -compress {"value":5,"name":"timeout"}
It does work if you Call ConvertTo-Json directly though.
PS > ConvertTo-Json $vars -compress [{"value":5,"name":"timeout"}]
So I believe the code should be something like this:
# Create quick job request $quickJobRequest.Add('jobName',$jobName) $jobComponent.Add('componentUid',$componentUid) $variables = @() + $variables $jobComponent.Add('variables',$variables) $quickJobRequest.Add('jobComponent',$jobComponent) # Convert to JSON $Body = ConvertTo-Json $quickJobRequest -depth 3
You're right, the component variables should be passed as a JSON array. Thanks for the input, I'll make the changes in the next release :-)
/v2/device/{deviceUid}/quickjob requires that the variables field be an array. If you pipe a single item array to ConvertTo-Json the returned json is no longer an array.
It does work if you Call ConvertTo-Json directly though.
So I believe the code should be something like this: