I'm trying to automate creating git repositories for my team. I need to use the Web Api, NOT the .NET API. The call I'm trying to use is this one which responds, but returns the following error body within a HTTP/1.1 400 Bad Request:
{"$id":"1","innerException":null,"message":"Bad parameters. A repository with a team project and a name are required.","typeName":"System.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089","typeKey":"ArgumentException","errorCode":0,"eventId":0}
The error message is: Bad parameters. A repository with a team project and a name are required.
Here's my code:
var projectName = "testing";
var url = ConfigurationManager.AppSettings["TFS-Url"] + "/_apis/git/repositories/?api-version=1.0";
var data = "{ \"name\": \"" + projectName + "\", \"project\": { \"id\": \"" + ConfigurationManager.AppSettings["TFS-Parent-Project-Guid"] + "\", \"name\": \"" + ConfigurationManager.AppSettings["TFS-Parent-Project-Name"] + "\" } }";
var wc = new WebClient();
wc.Credentials = new NetworkCredential("user", "pass");
var res = wc.UploadString(url, data);
I have tried this without the "name" of the project - (like the example does), without the "id", with varying "id" guids gathered from the Get Repositories Api.
No matter what I try, the same error is returned. Any ideas?