Python - Return "Name" of All Projects in Workspace

Hi All -
I successfully used CURL to do the same thing but I am moving to Python and I continue to get returns of 0. All I want at this point is for the return to include the name of all my projects. I’m basing my sample off the docs:

result = client.projects.get_projects_for_workspace(‘MYWORKSPACEID’, {‘param’: ‘value’, ‘param’: ‘value’}, opt_pretty=True)

What should I be putting in for “param” and “value” fields above.

Thank you.


It will probably work if you don’t put any params. But you might be able to use opt_fields` to choose the fields you want to receive. Did you check the Python client source code?


No params returns no error but returned 0. I’ll not sure what you mean by did I check client source code.

According to docs gid should always be returned but that’s not happening.

Thanks again.

We don’t have enough informations to help you…

That link shows that you can add opt_fields parameters and you will get it in response.
I think that you may have an error in return?
“0” is not a valid return, if no projects are available, you will get an empty array, not “0”.

If you only use that query without parameters, do you get your response?
result = client.projects.get_projects_for_workspace(“123456789”)

Fields “gid” and “name” are returned by default if you don’t specify any opt_fields.

Sorry let me go ahead and give more info.

The following CURL command works fine and returns the 3 projects that I have in Asana:

curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer MyToken' | jq -r '.data[].name'}

The following Python code returns an empty array:

import asana

# replace with your personal access token.
personal_access_token = 'MyToken'

# Construct an Asana client
client = asana.Client.access_token(personal_access_token)

# Get your user info
me =

# Print all projects
result = client.projects.get_projects_for_workspace('MyWorkspaceID', opt_pretty=True)

Based on the docs it seems like omitting any parameter/value pairs should result in gid and name of projects being returned with the above command.

Still hoping to get a resolution on this one…anything else needed from my end to figure out why I’m getting an empty array?

How did you find out your own workspaceId?

By going here:

and I can see my three projects here:[MyWorkSpaceID]/projects?opt_fields=name&limit=10

Of course MyWorkSpaceID is taken from the first link and is the same that I’m putting in curl command (which works) and my Python code (which does not).

Your only chance for me is to log whatever call the Python code is doing, including params, and compare with your cURL command to find differences.

I set up a sandbox account essentially:

${exec curl -X GET -H ‘Accept: application/json’ -H ‘Authorization: Bearer 1/1202520163969601:c176875c1c8571ac28f1a20d6226c8e9’ | jq -r ‘’}

that code is executed in conky and works perfectly fine.

Following appears to be returning empty string:

# replace with your personal access token.

import asana

personal_access_token = ‘1/1202520163969601:c176875c1c8571ac28f1a20d6226c8e9’

# Construct an Asana client

client = asana.Client.access_token(personal_access_token)

# Get your user info

me = [](

# Print all projects

result = client.projects.get_projects_for_workspace(‘1202520164009516’, opt_pretty=True)

If I add print (result) I get the following error:
<generator object PageIterator.items at 0x7fcd2da6df50>

Process finished with exit code 0

I am a bit lost but what I can tell you is that this method seems to be returning a Collection, and not a flat list of items. That’s the case in nodeJS, and the error around PageIterator seems to indicate it. Do you know how to read a collection from the Asana API in Python?