task.completed always equals false

Briefly describe (1-2 sentences) the Bug you’re experiencing: I have been using the api to create an application that gets important workflow data from projects within a workspace. However, whenever I use an IDE, I am getting this weird bug for the “completed field” where whenever I call that method, it always returns as false, regardless of the actual completion. Not to mention, I am still capable of changing tasks from complete to incomplete and vice versa, but it will still always say false. I am even more confused now because everything seems to be working fine in Postman, it’s just whenever I use an IDE that I get this bug.

Steps to reproduce: 1. Get all tasks in your project 2. Create an enhanced for loop to cycle through all the tasks and print to the console the name of the task and whether or not it is complete. 3. run the program.

If you get the same bug, the names will all correspond to the asana project, but it will always say false for completion.

Browser version: Windows 10 Pro

Upload screenshots below:
My code:
List tasks = client.tasks.findByProject(project.gid)
.execute();

    for(Task t : tasks){
        System.out.println(t.name);
        System.out.println(t.completed);
    }

Output:
Task 1
false
Task 2
false
Task 3
false

Seems normal, until I see the project on Asana and know for a fact that Task 1 and Task 2 are both marked as complete. Furthermore, I also always get null for the custom fields applied to it even though I applied a custom field to these tasks. This has been really slowing down my development lately and a quick response would be helpful, thanks.

Hi @Vincent_Di_Iorio, welcome to the Asana Community Forum! I’m moving your report to the #developersapi category so one of our developers can help you.

Hi @Vincent_Di_Iorio,

If it’s working fine in Postman (plus I know it works for my app with no issues), then everything is A-OK on the Asana end and it has to be something specific to your client IDE environment or how you’re doing the call there.

Can you give some more details about your IDE environment and how you’re doing the call there - and what’s different from how you’re doing it in Postman - since that has to be the key here?

1 Like

I am using IntelliJ IDEA Community Edition 2021.2 and I am using Maven for dependencies. I thought it could be the IDE, so I also tried VS Code and the results were the same. Is there perhaps a specific archetype I am supposed to use for Maven? The difference in the call is that I am using the direct endpoint in Postman, it seems like there could be some sort of deprecation for the Java API, but I have been unable to find information on it.

You’re using the official Java Asana client library?

1 Like

Yes

I think the explanation is that if you look at that method in the java library source, you’ll see that it returns compact task records:

/**
     * ***Returns the compact task records*** for all tasks within the given project,
     * ordered by their priority within the project.
     *
     * @param  project The project in which to search for tasks.
     * @return Request object
     */
    public CollectionRequest<Task> findByProject(String project) {

        String path = String.format("/projects/%s/tasks", project);
        return new CollectionRequest<Task>(this, Task.class, path, "GET");
    }

Compact task records don’t include any fields other than the task name:
https://developers.asana.com/docs/task-compact

In order to get other fields like completed or custom_fields you’ll have to use the opt_fields option to ask for them specifically:
https://developers.asana.com/docs/input-output-options

5 Likes

That helped, it is working now. Thanks.

1 Like

This topic was automatically closed after 6 days. New replies are no longer allowed.