Actions
Feature #38495
closedJava API - Issue Redmine
Status:
Closed
Priority:
Normal
Assignee:
-
Category:
REST API
Target version:
-
Start date:
Due date:
% Done:
0%
Estimated time:
Resolution:
Invalid
Description
public String doPostIssue() throws IOException {
DefaultHttpClient httpclient = new DefaultHttpClient();
httpclient.getCredentialsProvider().setCredentials(
new AuthScope("redmine.org/issues", 80),
new UsernamePasswordCredentials("admin", "admin"));
HttpPost httpPost = new HttpPost("http://www.redmine.org/issues");
System.out.println("executing request:\n" + httpPost.getRequestLine());
HttpEntity entity = new EntityTemplate(cp);
httpPost.setEntity(entity);
HttpResponse response = httpclient.execute(httpPost);
HttpEntity responseEntity = response.getEntity();
String value = "";
System.out.println("----------------------------------------");
System.out.println(response.getStatusLine());
if (responseEntity != null) {
System.out.println("Response content length: "
+ responseEntity.getContentLength());
value = responseEntity.getContent().toString();
}
System.out.println(EntityUtils.toString(responseEntity));
httpclient.getConnectionManager().shutdown();
return value;
}
ContentProducer cp = new ContentProducer() {
public void writeTo(OutputStream outstream) throws IOException {
Writer writer = new OutputStreamWriter(outstream, "UTF-8");
writer.write("format=json&action=new&");
String payload = "{\"issue\": {\"subject\": \"New Issue by Eliana\",\"description\": \"Some description\",\"tracker_id\": \"1\",\"priority_id\":\"3\",\"custom_fields\": [{\"id\": \"1\", \"value\": \"" + new Random().nextInt() + "\"}]}}";
writer.write(payload);
writer.flush();
}
};
I have this response:
POST http://www.redmine.org/issues HTTP/1.1 ---------------------------------------- HTTP/1.1 301 Moved Permanently Response content length: 0
How should I fix it?
Updated by Holger Just almost 2 years ago
- Description updated (diff)
- Status changed from New to Closed
- Resolution set to Invalid
http://www.redmine.org redirects to https://www.redmine.org. Plain HTTP requests are not served anymore. You may want to update your requests to use the https protocol.
In any case though, please note that https://reddmine.org is the live issue tracker of the Redmine project. Please do not use it for testing your scripts. Instead, please setup your own local Redmine installation or use the installation or your organisation for testing.
Actions