I'm trying to create an agent pool (Azure devops Server) using powershell and invoke-restmethod. To do this I'm using the reference below to try a build up a correct json request body. https://docs.microsoft.com/en-us/rest/api/azure/devops/distributedtask/pools/add?view=azure-devops-rest-5.1 All basics in place (credentials etc - I have successfully run other tasks using other uris) Many attempts at finding the correct body, all pretty much with the same result, latest example below;
$requestBodyAgentPool = '{
"Id": "3"
"name": "Testpool",
"isHosted": $false,
"autoSize": $false,
"poolType": "automation",
"isLegacy": $false
}'
Using the following (verified the uri and credentials by running a GET)
$uriPool = "http://localhost/DefaultCollection/_apis/distributedtask/pools?api-version=5.1"
Invoke-RestMethod -Uri $uriPool -Method POST -ContentType 'application/json' -Body $requestBodyAgentPool -Credential $cred
Fails with below which to me means the parameter id is null.
Invoke-RestMethod : {"$id":"1","innerException":null,"message":"Value cannot be null.\r\nParameter name: pool.Name","typeName":"System.ArgumentNullException, mscorlib","typeKey":"ArgumentNullException","errorCode":0,"eventId":0}
I have a feeling this is just my inexperience with coding terms and reading the reference documentation but it is not clear to me if the format is wrong or I'm missing/wrong format a mandatory parameter (id or name?)