Java DefaultHttpClient HTTP PUT 和 Cookie
Java DefaultHttpClient HTTP PUT and Cookie
我正在向 YouTrack api 发送创建问题的请求。
String url = yBaseUrl + "/rest/issue?Task&"+ URLEncoder.encode(subject)+"&"+URLEncoder.encode(desc);
HttpClient client = new DefaultHttpClient();
HttpPut request = new HttpPut(url);
// add request header
((DefaultHttpClient) client).setCookieStore(cookie);
HttpResponse response = null;
//client.execute(post);
try {
response = client.execute(request);
System.out.println(response.getStatusLine().getStatusCode());
} catch (IOException e) {
e.printStackTrace();
}
结果 - 403 代码。
为什么 setCookieStore 不起作用?
问题不正确 api url。需要用到/rest/issue?project=Task&summary="+ URLEncoder.encode(subject)...问题关闭
我正在向 YouTrack api 发送创建问题的请求。
String url = yBaseUrl + "/rest/issue?Task&"+ URLEncoder.encode(subject)+"&"+URLEncoder.encode(desc);
HttpClient client = new DefaultHttpClient();
HttpPut request = new HttpPut(url);
// add request header
((DefaultHttpClient) client).setCookieStore(cookie);
HttpResponse response = null;
//client.execute(post);
try {
response = client.execute(request);
System.out.println(response.getStatusLine().getStatusCode());
} catch (IOException e) {
e.printStackTrace();
}
结果 - 403 代码。
为什么 setCookieStore 不起作用?
问题不正确 api url。需要用到/rest/issue?project=Task&summary="+ URLEncoder.encode(subject)...问题关闭