Search code examples
asanaasana-api

Asana API (Java) - Fetching the tasks's due date


I am using the API code developed in Java and I am trying to obtain the due date for a task. When I use the following lines of code, I get "null":

List<Task> tasks = client.tasks.findByProject(demoProject.id).execute();

for(int i = 0; i < tasks.size(); i++)
    {
        if(tasks.get(i).id.equals("............"))
        {
            System.out.println(tasks.get(i).name +", "+ tasks.get(i).dueOn);
        }
    }

Could somebody get back to me on this please? I have posted ".........." for the task ID, but it is a valid ID.

Thanks!


Solution

  • I work at Asana. It looks like the endpoint you are using returns a compact representation (name and id only).

    You'll need to specify the fields you want to include in options like so: List tasks = client.tasks.findByProject(<"....">).option("fields", "name,due_on").execute();

    Hope this helps!

    For reference:

    https://asana.com/developers/api-reference/tasks#query https://asana.com/developers/documentation/getting-started/input-output-options