Getting 500 Server Error for API Calls (1)

Hello Community,

We are using Asana Python SDK for API Calls to get Stories for the Tasks, but the SDK is throwing 500 error:

asana.error.ServerError: Server Error: Oops! An unexpected error occurred 
    while processing this request. The input may have contained something 
    the server did not know how to handle. For more help, please contact 
    api-support@asana.com and include the error phrase from this response.

The API Calls we are doing are as follows:

  1. Get all Workspaces
  2. Get all Projects in Workspaces
  3. Loop over every Project and get all Tasks
  4. Get Stories for all the Tasks using SDK function: get_stories_for_task

In the stack trace, we can see the error is coming from the get_stories_for_task function of Asana Python SDK.
Please see the Reference for function and API Endpoint.

Can someone help me out with this issue?

Thanks.

Hi,

I have those errors when the request being made is incorrect, based on the documentation. Maybe the Python lib has an issue, or you are not passing the right params. Can you check what request is being made (endpoint+params) by logging inside the client library code?

Take care

Yes, @Bastien_Siebman, here is the API call:

API Call: /tasks/task_gid/stories

Params: {'limit': 50, 'opt_fields': 'gid,resource_type,created_at,created_by,resource_subtype,text,html_text,is_pinned,assignee,dependency,duplicate_of,duplicated_from,follower,hearted,hearts,is_edited,liked,likes,new_approval_status,new_dates,new_enum_value,new_name,new_number_value,new_resource_subtype,new_section,new_text_value,num_hearts,num_likes,old_approval_status,old_dates,old_enum_value,old_name,old_number_value,old_resource_subtype,old_section,old_text_value,preview,project,source,story,tag,target,task'}

Other Options: {'base_url': 'https://app.asana.com/api/1.0', 'item_limit': None, 'page_size': 50, 'poll_interval': 5, 'max_retries': 5, 'full_payload': True, 'iterator_type': 'items', 'opt_fields': 'gid,resource_type,created_at,created_by,resource_subtype,text,html_text,is_pinned,assignee,dependency,duplicate_of,duplicated_from,follower,hearted,hearts,is_edited,liked,likes,new_approval_status,new_dates,new_enum_value,new_name,new_number_value,new_resource_subtype,new_section,new_text_value,num_hearts,num_likes,old_approval_status,old_dates,old_enum_value,old_name,old_number_value,old_resource_subtype,old_section,old_text_value,preview,project,source,story,tag,target,task', 'timeout': 300, 'limit': 50}

Did you try reducing the op_fields to only “gid” for example, to rule out any wrongly typed field? @Phil_Seeman any idea? Does it work with Postman or an equivalent?

I definitely endorse what @Bastien_Siebman said - try it without the opt_fields. If that works, you know the issue is somewhere in the field list (which is my first hunch as the problem source). Then you can start adding in fields until it breaks. Or if it doesn’t work with no opt_fields then we know the problem source is elsewhere.

So follow Bastien’s suggestion first.

1 Like

Whenever you say I am right @Phil_Seeman I have some butterflies in my stomach :heart:

1 Like