Adding a new BuildConfiguration via API fails with 400 Bad Request

Following the instructions on this page: https://confluence.jetbrains.com/display/TCD18/REST+API#RESTAPI-BuildConfigurationAndTemplateSettings it says

Create a new empty build configuration: POST plain text (name) to http://teamcity:8111/app/rest/projects/<projectLocator>/buildTypes 

 

I am trying to script the creation of a new BuildConfiguration within our Microservices project, using the following PowerShell script:

$cred = Get-Credential
$uri = 'http://teamcityserver:81/httpAuth/app/rest/projects/id:Microservices/buildTypes'
$newName = 'Sample.Project.Name'
Invoke-WebRequest -Uri $uri -Credential $cred -Method Post -Body $newName -ContentType 'text/plain'

The response, though, is:

Invoke-WebRequest : The remote server returned an error: (400) Bad Request.

I'm probably doing something very ignorant. I'd appreciate any gentle pointers to overcome this. 

thanks,
David

0
1 comment
Avatar
Permanently deleted user

Hmmm, I'm wondering if one of my attempts actually succeeded, creating the project. Then all subsequent attempts failed with 400 Bad Request, because I was trying to create a project with a name that clashed with one that already exists. 

I'll add a test to check that the project does not exist before trying to create it. 

0

Please sign in to leave a comment.