Asana / python-asana

Official Python client library for the Asana API v1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`completed_since` does not work anymore in new API

MRyderOC opened this issue · comments

commented

Hi,
There was a keyword for the get_tasks_for_section method called completed_since. In the previous version of the API (3.2.1) it worked properly but not with 4.0.7 release it does not work anymore. Also, note that this keyword is not present in the documentation, I found it in the forum.

3.2.1 example:

my_asana_token = "<SOME_TOKEN>"
section_gid = "1234"
completed_since = "2023-08-01"

client_asana = asana.Client.access_token(my_asana_token)
client_asana.tasks.get_tasks_for_section(section_gid, completed_since=completed_since)

Hi @MRyderOC,

I am taking a look at the method definition for get_tasks_for_section in our python-asana (v3.2.1) and it doesn't look like we documented that completed_since being a query param. We also don't have this query param documented in our developer docs.

completed_since

That being said, I can see thatcompelted_sincequery param is defined in our API and works for this endpoint. I'll check with our team if this is something we forgot to document or if it was documented and removed but the functionality was there for backwards compatibility reasons. Depending on their response we'll update our python library and developer docs.

As a workaround feel free to use our call_api method for our python-asana (v4.X.X)

EX:

import asana
from asana.rest import ApiException
from pprint import pprint

# Configure OAuth2 access token for authorization: oauth2
configuration = asana.Configuration()
configuration.access_token = '<YOUR_PERSONAL_ACCESS_TOKEN>'
api_client = asana.ApiClient(configuration)

try:
    # GET - get a task
    api_response = api_client.call_api(
        "/sections/{section_gid}/tasks",
        "GET",
        path_params={"section_gid": "<YOUR_SECTION_GID>"},
        query_params=[('completed_since', '2023-08-01')],
        header_params={"Accept": "application/json; charset=utf-8"},
        body=None,
        post_params=[],
        files={},
        response_type=object, # If there is an existing response model for the resource you can use that EX: "TaskResponseData" or you can specify one of the following types: float, bool, bytes, str, object
        auth_settings=["oauth2"],
        async_req=None,
        _return_http_data_only=True,
        _preload_content=True,
        _request_timeout=None,
        collection_formats={},
    )
    pprint(api_response)
except ApiException as e:
    print("Exception: %s\n" % e)

@MRyderOC I've confirmed with our team that this was something we forgot to document. We've gone ahead and updated both our developer docs and python client libraries to include this query parameter. We've deploy the changes for python in v4.0.8 so you should be able to make a get_tasks_for_section request with the completed_since query param now if you update:

import asana
from asana.rest import ApiException
from pprint import pprint

# Configure OAuth2 access token for authorization: oauth2
configuration = asana.Configuration()
configuration.access_token = '<YOUR_PERSONAL_ACCESS_TOKEN>'
api_client = asana.ApiClient(configuration)

# create an instance of the API class
api_instance = asana.TasksApi(api_client)
section_gid = '<YOUR_SECTION_GID>' # str | The globally unique identifier for the section.eter to the next request. If an offset is not passed in, the API will return the first page of results. 'Note: You can only pass in an offset that was returned to you via a previously paginated request.' (optional)
completed_since = '2023-08-01T00:00:00.000Z' # str | Only return tasks that are either incomplete or that have been completed since this time. Accepts a date-time string or the keyword *now*.  (optional)

try:
    # Get tasks from a section
    api_response = api_instance.get_tasks_for_section(section_gid, completed_since=completed_since)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling TasksApi->get_tasks_for_section: %s\n" % e)    

Thanks for reporting. I am going to close this issue now that this has been fixed. Let us know if you run into any more issues.

commented

@jv-asana Thanks a lot for making this available. Just tested it and it works like a charm. Thanks!