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 https://app.asana.com/api/1.0/projects//task_counts?opt_pretty=false&limit=50
    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.

References
  • [1] com.google.http-client/google-http-client/1.20.0/5140e4d6fc293ede7dee965e8f3426d3e9e3d0c0/google-http-client-1.20.0-sources.jar!/com/google/api/client/http/HttpRequest.java:862
  • [2] com.asana/asana/0.10.1/fea2bd16f4426fad8ae4aef42bfde7c7b03692ea/asana-0.10.1-sources.jar!/com/asana/Client.java:201
  • [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…

2 Likes

@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 https://github.com/Asana/java-asana.