Python client library: using the Search API

Hi team.
I am facing this issue when using the Search Tasks API.

If I send the request like this it works like a charm:

issues = self.client.tasks.search_tasks_for_workspace(
  workspace_gid='XXXXX',
  params={'completed': True},
  opt_fields=['gid', 'name', 'assignee.gid', 'assignee.name', 'completed_at', 'projects.gid', 'projects.name']
)

But for reducing the amount of data to process on my side, I need to get the tasks closed after a given date. And then, the following query fails with the error: You must specify at least one search filter:

issues = self.client.tasks.search_tasks_for_workspace(
  workspace_gid='XXXXX',
  params={'completed_at_after': a_given_iso_date, 'sort_by': 'completed_at'},
  opt_fields=['gid', 'name', 'assignee.gid', 'assignee.name', 'completed_at', 'projects.gid', 'projects.name']
)

It doesn’t make sense to me. I am using a search filter in both cases, completed and completed_at_after.

Is there any Python library team member who can shed some light on this matter?

‘completed_at.after’

Merci, @Frederic_Malenfant !

I was trying to pass the parameter exactly as it was specified in the core library’s description.
Maybe this part should also be specified in more detail in documentation, for avoiding this kind of silly mistakes.

Thanks for your quick response.

1 Like

Where exactly is that error in the documentation? You can add the link here and someone will certainly fix it!

/resources/gen/tasks.py
The following code starts at line 350.

No parameter was described with a dot instead of an underscore:

    def search_tasks_for_workspace(self, workspace_gid, params=None, **options):
        """Search tasks in a workspace
        :param str workspace_gid: (required) Globally unique identifier for the workspace or organization.
        :param Object params: Parameters for the request
            - text {str}:  Performs full-text search on both task name and description
            - resource_subtype {str}:  Filters results by the task's resource_subtype
            - assignee_any {str}:  Comma-separated list of user identifiers
            - assignee_not {str}:  Comma-separated list of user identifiers
            - assignee_status {str}:  One of `inbox`, `today`, `upcoming`, or `later`
            - portfolios_any {str}:  Comma-separated list of portfolio IDs
            - projects_any {str}:  Comma-separated list of project IDs
            - projects_not {str}:  Comma-separated list of project IDs
            - projects_all {str}:  Comma-separated list of project IDs
            - sections_any {str}:  Comma-separated list of section or column IDs
            - sections_not {str}:  Comma-separated list of section or column IDs
            - sections_all {str}:  Comma-separated list of section or column IDs
            - tags_any {str}:  Comma-separated list of tag IDs
            - tags_not {str}:  Comma-separated list of tag IDs
            - tags_all {str}:  Comma-separated list of tag IDs
            - teams_any {str}:  Comma-separated list of team IDs
            - followers_any {str}:  Comma-separated list of user identifiers
            - followers_not {str}:  Comma-separated list of user identifiers
            - created_by_any {str}:  Comma-separated list of user identifiers
            - created_by_not {str}:  Comma-separated list of user identifiers
            - assigned_by_any {str}:  Comma-separated list of user identifiers
            - assigned_by_not {str}:  Comma-separated list of user identifiers
            - liked_by_any {str}:  Comma-separated list of user identifiers
            - liked_by_not {str}:  Comma-separated list of user identifiers
            - commented_on_by_any {str}:  Comma-separated list of user identifiers
            - commented_on_by_not {str}:  Comma-separated list of user identifiers
            - due_on_before {date}:  ISO 8601 date string
            - due_on_after {date}:  ISO 8601 date string
            - due_on {date}:  ISO 8601 date string or `null`
            - due_at_before {datetime}:  ISO 8601 datetime string
            - due_at_after {datetime}:  ISO 8601 datetime string
            - start_on_before {date}:  ISO 8601 date string
            - start_on_after {date}:  ISO 8601 date string
            - start_on {date}:  ISO 8601 date string or `null`
            - created_on_before {date}:  ISO 8601 date string
            - created_on_after {date}:  ISO 8601 date string
            - created_on {date}:  ISO 8601 date string or `null`
            - created_at_before {datetime}:  ISO 8601 datetime string
            - created_at_after {datetime}:  ISO 8601 datetime string
            - completed_on_before {date}:  ISO 8601 date string
            - completed_on_after {date}:  ISO 8601 date string
            - completed_on {date}:  ISO 8601 date string or `null`
            - completed_at_before {datetime}:  ISO 8601 datetime string
            - completed_at_after {datetime}:  ISO 8601 datetime string
            - modified_on_before {date}:  ISO 8601 date string
            - modified_on_after {date}:  ISO 8601 date string
            - modified_on {date}:  ISO 8601 date string or `null`
            - modified_at_before {datetime}:  ISO 8601 datetime string
            - modified_at_after {datetime}:  ISO 8601 datetime string
            - is_blocking {bool}:  Filter to incomplete tasks with dependents
            - is_blocked {bool}:  Filter to tasks with incomplete dependencies
            - has_attachment {bool}:  Filter to tasks with attachments
            - completed {bool}:  Filter to completed tasks
            - is_subtask {bool}:  Filter to subtasks
            - sort_by {str}:  One of `due_date`, `created_at`, `completed_at`, `likes`, or `modified_at`, defaults to `modified_at`
            - sort_ascending {bool}:  Default `false`
        :param **options
            - opt_fields {list[str]}:  Defines fields to return. Some requests return *compact* representations of objects in order to conserve resources and complete the request more efficiently. Other times requests return more information than you may need. This option allows you to list the exact set of fields that the API should be sure to return for the objects. The field names should be provided as paths, described below. The id of included objects will always be returned, regardless of the field options.
            - opt_pretty {bool}:  Provides “pretty” output. Provides the response in a “pretty” format. In the case of JSON this means doing proper line breaking and indentation to make it readable. This will take extra time and increase the response size so it is advisable only to use this during debugging.
        :return: Object
        """
        if params is None:
            params = {}
        path = "/workspaces/{workspace_gid}/tasks/search".replace("{workspace_gid}", workspace_gid)
        return self.client.get_collection(path, params, **options)

@Frederic_Malenfant
The error is not in the documentation, but in the methods description in the library itself.
Maybe it is not even an error, but it is confusing for newbies like me :slight_smile:

I am more than a newbie, I never did any Python!
But, just to be sure, did it work when you use the “dot” instead?
If yes, @Ross_Grambo I think is the one that can look at the doc and fix that example!

1 Like

Yes, using the ‘dot’ notation worked perfectly. Thank you.
I did not check correctly the API Explorer first, that’s why I did not notice it before, and I was trying to use the search parameters with underscore.

Oh whoops! Thank you for finding this issue with the _ instead of . syntax. I believe it was a limitation of our code generator at the time but it should be resolvable now. I’ll make a task for it.

1 Like

Great, thank you guys for your help.