I am trying to queue a build from my TFS servers using the TFS Rest API nuget package for c#. However, upon sending the request to the server with the JSON:
"definition":{ "id":63 }
I get a 400 response back with the error:
message=Value cannot be null. Parameter name: build.Definition
I think I am sending the JSON correctly, considering before I was getting errors saying it couldnt be deserialized, or that there wasnt a JSON in the first place.
Can someone help me figure out what is causing this error and how to fix it?
For reference and showing what I have already used as help:
Again Queueing a build in powershell
And several other articles (google "queue build tfs rest api c#")
//post request for queuing the build
var client = new RestClient(websiteName);
var request = new RestRequest("_apis/build/builds?ignoreWarnings=true&sourceBuildId=63&api-version=4.0", Method.POST, DataFormat.Json);
Dictionary<string, string> values = new Dictionary<string, string>();
values.Add("{\"definition\"", "{\"id\":63}}");
request.AddHeader("Authorization", "Basic " + Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", "", personalAccessToken))));
request.AddJsonBody(values);
IRestResponse response = client.Execute(request);