I am using REST API to create a work item using REST API documentation.For this, i need to use Patch request, but this code not working. program exiting with code 0 (0x0).
HttpClientHandler httpClientHandler = new HttpClientHandler();
using (HttpClient client = new HttpClient(httpClientHandler))
{
var content = "[{'op': 'add','path': '/fields/System.Title', 'value': 'Title' }]";
client.DefaultRequestHeaders.Accept.Add(
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
string URLTest = "https://MyProject.visualstudio.com/DefaultCollection/ProjectName/_apis/wit/workitems/$Task?api-version=2.0";
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", "*******", "******"))));
var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(method, URLTest)
{
Content = new StringContent(content, Encoding.UTF8,
"application/json-patch+json")
};
HttpResponseMessage response = await client.SendAsync(request);