Project

General

Profile

Using the REST API with PHP - Redmine

Added by gabriel visconti over 9 years ago

I'm using this API to get issues of a redmine database.

http://www.redmine.org/projects/redmine/wiki/Rest_api_with_php

I followed the examples, but I can't get issues where assigned_to_id is null.

Here's the code I tried so far.

require_once ('ActiveResource.php');

class Issue extends ActiveResource {
var $site = 'root:12345@localhost/redmine';
var $request_format = 'xml'; // REQUIRED!
var $element_name = 'issue'
}

$issue = new Issue();
$issues = $issue->find('all'); //Works fine
print_r($issues);

But when I try to restrict for null value in assigned_to_id, It's not working.

$issues = $issue->find ("all", array('assigned_to_id'=>null)); //not working
$issues = $issue->find (false, array('assigned_to_id'=>null)); //not working
$issues = $issue->get ('by_assigned_to_id', array('assigned_to_id' => null)) //not working

What's wrong? What am I missing?


Replies (3)

RE: Using the REST API with PHP - Redmine - Added by Alessandro Gustavo over 9 years ago

gabriel visconti wrote:

I'm using this API to get issues of a redmine database.

http://www.redmine.org/projects/redmine/wiki/Rest_api_with_php

I followed the examples, but I can't get issues where assigned_to_id is null.

Here's the code I tried so far.

[...]

But when I try to restrict for null value in assigned_to_id, It's not working.

[...]

What's wrong? What am I missing?

Hey man, whats version are you using of php-api?

If you try a query command:

SELECT * FROM redmine.issues WHERE assigned_to_id = null;

You won't have results.

But, if you try a query command:

SELECT * FROM redmine.issues WHERE assigned_to_id is null;

It will shows all results where assigned_to_id is null. You can make a test on terminal or ide workbench.

RE: Using the REST API with PHP - Redmine - Added by gabriel visconti over 9 years ago

Ok, but thats not the problem since this API does not run any sql.

I'm getting close to solve. The problem is because assigned_to_id is null in database, the XML is not creating this tag, therefore the API its not filtering. But when assigned_to_id is an integer, the tag is created and the filter works.

I'm trying to find the point where ActiveResource.php is testing for null and eliminating the creation of this tag.

RE: Using the REST API with PHP - Redmine - Added by Alessandro Gustavo over 9 years ago

I think you can't do it!

Optional filters:

  • project_id: get issues from the project with the given id, where id is either project id or project identifier
  • subproject_id: get issues from the subproject with the given id. You can use project_id=XXX&subproject_id=!* to get only the issues of a given project and none of its subprojects.
  • tracker_id: get issues from the tracker with the given id
  • status_id: get issues with the given status id only. Possible values: open, closed, * to get open and closed issues, status id
  • assigned_to_id: get issues which are assigned to the given user id. me can be used instead an ID to fetch all issues from the logged in user (via API key or HTTP auth)
  • cf_x: get issues with the given value for custom field with an ID of x. (Custom field must have 'used as a filter' checked.)
  • ...

http://www.redmine.org/projects/redmine/wiki/Rest_Issues

However, if you try to create a new custom field where this field is "0" when you don't set a responsible to your task.

Look: cf_x: get issues with the given value for custom field with an ID of x. (Custom field must have 'used as a filter' checked.)

I'm so sorry if I'm wrong. I'm new member on Redmine!

    (1-3/3)