Search code examples
javaasanaasana-api

GET /tasks does not work


I'm using Query Tasks method: https://asana.com/developers/api-reference/tasks#query using following code snipet:

    String url = API_BASE+"/tasks?completed_since=now";
    System.out.println(url);
    HttpGet httpget = new HttpGet(url);

    httpget.addHeader( BasicScheme.authenticate(creds, "US-ASCII", false) );

    ResponseHandler<String> responseHandler = new BasicResponseHandler();

    String responseBody = httpclient.execute(httpget, responseHandler);

ERROR:

https://app.asana.com/api/1.0/tasks?completed_since=now
null
org.apache.http.client.HttpResponseException: Bad Request
    at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:67)
    at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:54)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:735)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:709)
    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:700)

Solution

  • I work at Asana.

    Yes, the underlying message from the server is:

    "Must specify exactly one of project, tag, or assignee + workspace"

    We'll take a look at updating the documentation for this since it does appear to be explicit with regards to this.

    I highly recommend using url as indicated in the examples.

    Also, we have a Java client library that you may find useful: https://github.com/Asana/java-asana

    Thanks for bringing up the documentation issue.