Get issues by date not working

Issue #58 resolved
Constantin Kraft created an issue

Hey there, is there a way to get issues by date?

I tried the following code, but it gives me a Uncaught Buzz\Exception\RequestException: Operation timed out after 10000 milliseconds with 0 bytes received in /home/constantin/PhpstormProjects/bb-reports/vendor/kriswallsmith/buzz/lib/Buzz/Client/Curl.php:29

Code sample:

$issues = $this->issue->all($_ENV['BB_ACCOUNT'], $_ENV['BB_REPO'],
    array( 'state' => 'open', 'created_on' => ">= 2017-03-15T10:49:10+0000")
);

Do I have to specify an extra parameter?

Comments (3)

  1. Alexandru Guzinschi

    The problem is that Issues:all is still using v1 of the Bitbucket Api and filtering by creation date is available only in v2 of the Api.

    The solution is to manually tell the library to use v2 of the Bitbucket Api.

    <?php
    
    $issue = new \Bitbucket\API\Repositories\Issues();
    $issue->getClient()
        ->addListener(
            new \Bitbucket\API\Http\Listener\OAuth2Listener(/** oauth_params */)
        )
        ->setApiVersion('2.0')
    ;
    
    $issues = $issue->all($_ENV['BB_ACCOUNT'], $_ENV['BB_REPO'], [
        // https://developer.atlassian.com/bitbucket/api/2/reference/meta/filtering#query-issues
        'q' => 'state = "open" AND created_on >= 2017-03-15T10:49:10+00:00'
    ]);
    

    As a side note, be careful with the date format. The Api server is expecting the date to be ISO 8601, so instead of 2017-03-15T10:49:10+0000 it should be 2017-03-15T10:49:10+00:00.

  2. Log in to comment