Closed cwbusacker closed 11 months ago
Hi @cwbusacker,
Thank you for reporting this issue. Because of this we also discovered that we were missing a definition for the opt_fields
query params the documentation for Add a custom field to a project endpoint in our developer docs.
I have gone ahead and sent a fix for this issue you reported under v5.0.3. Thank you for reporting this and helping make our client library better. If you encounter any other issues please don't hesitate to create another GitHub issue.
Example request:
NOTE: since opt_fields
was missing from this endpoint and we added it in our docs the method generated now takes in an opts
argument. If you don't have any query params to provide just pass in empty dict {}
import asana
from asana.rest import ApiException
from pprint import pprint
configuration = asana.Configuration()
configuration.access_token = "<YOUR_ASANA_PERSONAL_ACCESS_TOKEN>"
api_client = asana.ApiClient(configuration)
# create an instance of the API class
projects_api_instance = asana.ProjectsApi(api_client)
body = {"data": {"custom_field": "1205866071064406"}}
project_gid = "<YOUR_PROJECT_GID>" # str | Globally unique identifier for the project.
opts = {}
try:
# Add a custom field to a project
api_response = projects_api_instance.add_custom_field_setting_for_project(body, project_gid, opts)
pprint(api_response)
except ApiException as e:
print("Exception when calling ProjectsApi->add_custom_field_setting_for_project: %s\n" % e)
Here's break down of the cause:
add_custom_field_setting_for_project
method calls the call_api
method with an empty list of query params (NOTE: even though you did not provide query params for this endpoint by default it sends an empty list of query params -> this should be an empty dict)api_client.py
file where call_api
-> __call_api
tries to convert the query param provided from a dict into a list of tuples. Because the default argument for query params provided was a empty list you run into the AttributeError: 'list' object has no attribute 'items'
errorTODO to Fix:
query_params
in add_custom_field_setting_for_project
method from list to dictapi_client.py
where call_api
tries to convert the query param provided from a dict into a list of tuples -> check if it is empty before trying to run this codeWhere to perform fix:
Since the new libraries are auto generated we want to modify the templates that the generator uses to generate the the methods and client
api.mustache
template file (this file is used by the generator to generate all the endpoints under this the api
folder)api_client.py
) is also auto generated by the generator from the api_client.mustache
template - This is where the conversion is being done and where we need to fixCommits:
Using Asana Package version 5.0.0
Trying to add a custom field in the following way:
causes the following exception:
Editing the source code in
call_api
appears to fix it, but not sure if that could break it elsewhere.