Redmine REST:名称和标识符不能为空

时间:2016-03-02 10:21:21

标签: php redmine activeresource

我正在使用ActiveResource通过PHP将新项目添加到我的redmine中。 编辑/获取项目非常合适。但添加一个新的似乎不起作用。 REST api返回:

<?xml version="1.0" encoding="UTF-8"?><errors type="array"><error>Name cannot be blank</error><error>Identifier cannot be blank</error><error>Identifier is too short (minimum is 1 characters)</error></errors>

它说名称和标识符是空的,但它们不是因为我已经在我的脚本中添加了它们。

我的代码是错误的还是还有别的东西?

error_reporting(E_ALL);
require_once ('ActiveResource.php');

class Project extends ActiveResource {
    var $site = 'http://redmine/';
    var $user = 'admin';
    var $password = 'admin';
    var $element_name = 'projects';
    var $request_format = 'xml'; // REQUIRED!
    var $extra_params = '?key=XXXX';
}

$project = new Project(array('name' => 'Tittel', 'identifier' => "shop", 'description' => 'asd'));
var_dump($project);
if ($project->save()) {
    echo 'succes';
} else {
    echo 'fail';
}

1 个答案:

答案 0 :(得分:0)

Fixed it myself. The $element_name should be non-plural. Changing it to project did the trick.