I'm trying to cherry pick a PR into a target branch via the devops api and I only get a "bad request". Any thoughts?
Here's a link to MS docs text
public async Task<bool> CherryPickAndApprovePRAsync(PullRequestRelation pr)
{
var prNumber = ParsePRIdFromURL(pr.Url);
var repositoryId = "c36e9497-5b57-4435-8731-e72bd9513484";
var reviewerId = "3b0bc2c3-7525-4613-922b-d284e2c68748";
var targetBranch = "chuck-test-branch-please-do-not-delete";
var base64Pat = Convert.ToBase64String(Encoding.ASCII.GetBytes($":{PAT}"));
var apiUrl = $"http://xx-azuredevops:8080/devops/ProductEngineering/MyProject/_apis/git/repositories/c36e9497-5b57-4435-8731-e72bd9513484/cherryPicks?api-version=7.1-preview.1"; ;
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64Pat);
var requestBody = new
{
generatedRefName = $"refs/heads/temp-cherry-pick-{prNumber}",
ontoRefName = $"refs/heads/{targetBranch}",
repository = "MemberEngagementPortal",
source = new { pullRequestId = "62950" }
};
JsonContent jc = JsonContent.Create(requestBody);
var content1 = Newtonsoft.Json.JsonConvert.SerializeObject(requestBody);
var content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(requestBody), Encoding.UTF8, "application/json");
var response = await client.PostAsJsonAsync(apiUrl, requestBody);
return true;
}
}
I've tried constructing this request body several different ways an I only get "bad request"