How to use the Task Count Endpoint for Projects in the java client library

Original post here New endpoint: project task counts

I struggle creating this request with the java client-lib "com.asana:asana:0.10.1" - I would assume that I just need to do the following:

client.projects.getTaskCountsForProject(projectId).option("fields", "num_tasks").execute()

But this always returns me an empty JSON object {} -what am I missing here?

Debugging the client I see the following:

  • The LowLevelHttpRequest uses the wrong url
    at [1]
  • This should be because in [2] the url doesn’t contain the opt_fields see [3]

But I’m still not sure what I might have configured wrong - any help would be very much appreciated.

  • [1]!/com/google/api/client/http/
  • [2] com.asana/asana/0.10.1/fea2bd16f4426fad8ae4aef42bfde7c7b03692ea/asana-0.10.1-sources.jar!/com/asana/
  • [3] url = { "opt_pretty" -> {Boolean@3443} false, "limit" -> {Integer@3444} 50

The only way for me to make it work is to hack it into the request query with:

ItemRequest request = client.projects.getTaskCountsForProject(projectId);
request.query.put("opt_fields", toFieldList(EnumSet.allOf(TaskCountField.class)));
return request.execute();

@Ross_Grambo any idea?

Any update here?

Ping @Ross_Grambo

If you change it from .option to .query it will work as expected.

I’m not sure why option isn’t working here…


@Ross_Grambo interesting - I would have expected the option way to work so this is surprising (also from the linked documentation it seems that it should be possible that way)

What are the next steps should I create a bug report like described here [1] and link this discussion?

[1] How to report a Bug

I created a task internally for us to work on this, but I’d appreciate if you created an issue in the repo

Created an java-client-library issue for it here