我试图通过RESTful在Redmine(V 2.3.4)中创建一个问题。我已阅读文档并尝试了无效的示例(HTTP-Code:404)。
POST http://easyredmine.digitronic.com/issues.xml
<?xml version="1.0"?>
<issue>
<project_id>1</project_id>
<subject>Example</subject>
<priority_id>4</priority_id>
</issue>
然后我尝试了这个并且它有效:
POST http://easyredmine.digitronic.com/projects/isda/issues.xml
<?xml version="1.0"?>
<issue>
<project_id>1</project_id>
<subject>Example</subject>
<priority_id>4</priority_id>
</issue>
我正在使用taskadapter Redmine API,它以第一种形式发送请求。
答案 0 :(得分:0)
在第一种情况下,您获得404 Not Found,因为项目(ID = 1)必须添加的问题不存在。在第二种情况下,忽略元素project_id中的值,因为您已在URL中指定了项目标识符。
答案 1 :(得分:0)
您必须指定内容类型标题,否则您将获得404
答案 2 :(得分:0)
我将redmine rest api与ruby一起使用,并且create方法对我有用。我使用json而不是xml。我的Web服务如下所示
id=-1
url = Configuration.redmine+"/issues.json"
uri = URI.parse(url)
req = Net::HTTP::Post.new(uri.request_uri)
req.basic_auth(user, pass)
req["Content-Type"] = "application/json"
payload = {
issue: {
project_id:project_id,
tracker_id:tracker_id,
status_id:status_id,
priority_id:priority_id,
subject:subject,
description:description,
fixed_version_id:fixed_version_id,
author_id:author_id,
}
}
req.body = payload.to_json
http = Net::HTTP.new(uri.host, uri.port)
response = http.request(req)
if response.code=="201"
data = JSON.parse(response.body)
id=data["issue"]["id"]
end
return id
end
这是红宝石代码。希望它对您有帮助