I am trying to create work item in visual studio team services using java. but i am getting error "HTTP code 203: Non-Authoritative Information". When the same thing i am trying with C# its working fine.
I am attaching both source code using C# and java. please check and let me know why i am getting this error.
JAVA
try {
CloseableHttpClient http = HttpClientBuilder.create().build();
String encoding = Base64.getEncoder().encodeToString((ACCESS_TOKEN).getBytes("ASCII"));
HttpGet get = new HttpGet(
"https://{account}.visualstudio.com/TestProject/_apis/wit/workitems/5?api-version=1.0");
get.setHeader("Authorization", "Basic " + encoding);
get.addHeader("content-type", "application/json");
HttpResponse response = http.execute(get);
String out = response.getEntity().toString();
System.out.println(response.getStatusLine().getStatusCode());
} catch (Exception e) {
System.out.println(e);
}
C#
try
{ var
personalaccesstoken = "PATFROMWEB";
using
(HttpClient client = new
HttpClient()) { client.DefaultRequestHeaders.Accept.Add( new
System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Authorization = new
AuthenticationHeaderValue("Basic",
Convert.ToBase64String( System.Text.ASCIIEncoding.ASCII.GetBytes( string.Format("{0}:{1}",
"",
personalaccesstoken)))); using
(HttpResponseMessage response = client.GetAsync( "https://{account}.visualstudio.com/TestProject/_apis/wit/workitems/5?api-version=1.0").Result)
{ response.EnsureSuccessStatusCode(); string
responseBody = await
response.Content.ReadAsStringAsync(); Console.WriteLine(responseBody); } } }
catch
(Exception ex) { Console.WriteLine(ex.ToString()); }