Podio api task due_date format

235 views Asked by At

I'm trying to get the Podio API (php-library) to return all tasks that have a due date withing a certain range. PodioTask::get_all() works fine, it returns all tasks (limited to 100). Of course that is not very useful so I add attributes as documented:

$tasks = PodioTask::get_all(array(
    'org' => [my_organization_id],
    'completed' => 'false',
    'limit' => 100
)
);

Up until here behavior is still as expected. As soon as I attempt to add the due_date-attribute I get an error message saying Uncaught PodioBadRequestError: "The values are not in the right format" Request URL: http://api.podio.com/task/?org=[my_organization_id]&completed=false&due_date=&limit=100

I try to do it like this, which works fine for the filters on Podio items:

$tasks = PodioTask::get_all(array(
    'org' => [my_organization_id],
    'completed' => 'false',
    'due_date' => array(
        'from' => '2d',
        'to' => '90d'
        ),
    'limit' => 100
)
);

I tried replacing the from and to dates with absolute ones in the YYYY-MM-DD format (as a string, but also tried a DateTime-object), but I get the same error. I tried removing the array and just setting a single date (as a string and a DateTime object) and none of it works. I keep getting the message that the values are not in the right format. The documentation tells me the due_date-parameter is "The from and to date the task should be due between. For valid options see date filtering under the filter area." If I go there I end up with the documentation for filtering items and I am doing the exact same thing here as for items, which I can filter by date. (https://developers.podio.com/doc/tasks/get-tasks-77949)

It appears like the php-library expects a string, but the API needs the 'from' and 'to' properties.

Anyone got any ideas?

1

There are 1 answers

0
Mûhámmàd Yäsår K On

Try this

     $attributes = array(
          'org' => [my_organization_id],
          'completed' => 'false',
          'limit' => 100,
          'due_date'=> $fromDate.'-'.$toDate 
        );
$tasks = PodioTask::get_all($attributes);

where $fromDate and $toDate are DateTime Objects.