# Python API - Getting Project IDs from Portfolios, Locked out of other portfolios

**URL:** <https://forum.asana.com/t/python-api-getting-project-ids-from-portfolios-locked-out-of-other-portfolios/46340>\
**Category:** API & Developers\
**Created:** [3 April 2019 16:55 UTC](https://forum.asana.com/t/python-api-getting-project-ids-from-portfolios-locked-out-of-other-portfolios/46340 "2019-04-03T16:55:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jake\_Olsby](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/jake_olsby/32/32003_2.png) [@Jake\_Olsby](https://forum.asana.com/u/Jake_Olsby)\
**Post date:** [3 April 2019 16:55 UTC](https://forum.asana.com/t/python-api-getting-project-ids-from-portfolios-locked-out-of-other-portfolios/46340/1 "2019-04-03T16:55:53Z")

</div>

Hi all,

I am working with the Python API, which is proving to be very useful. We are looking to automating pulls from the API to populate our datawarehouse for project analytics.

We have just moved to subscribing to business class, and I noticed that the python API doesn’t support portfolios in the way we expected.

Its a two part problem.

1. The python API is great, and has a method for projects called projects. **find\_by\_workspace**. However there isn’t an equivalent projects. **find\_by\_portfolio** method.

As such it was difficult to find the portfolio\_ids. To find portfolios we had to use the follow GET company instead:

#Note: the XXXX are just commenting our IDs

portfolios = client.get(‘/workspaces/XXXXXXXXXXXXXX/portfolios/?owner=XXXXXXXXXXXXXX’. We can get a list of the following:

, id  
, gid  
, resource\_type  
, name  
, owner  
, created\_at  
, custom\_field\_settings  
, color  
, workspace

I am thinking if there is a way to find our the portfolio id relates the project id, perhaps with some sort of bridge connection similar to how [Project Membership](https://asana.com/developers/api-reference/project_memberships) maps projects to users, if there was a some way to map Portfolios to projects.

**ASK: Is there a way to map projects to portfolios be it through one of the asana python API methods, or through some GET command I am not immediately seeing.**

1. We have also found that Portfolios throw an error if you don’t in fact own the portfolios with your token / account.

I receive the following error:

* * *

ForbiddenError Traceback (most recent call last)  
 in ()  
12 , color   
13 , workspace   
—\> 14 ’  
15  
16 })

C:\ProgramData\Anaconda2\lib\site-packages\asana\client.pyc in get(self, path, query, \*\*options)  
114 # options in the query takes precendence  
115 query = \_merge(query\_options, api\_options, parameter\_options, query)  
 → 116 return self.request(‘get’, path, params=query, \*\*options)  
117  
118 def get\_collection(self, path, query, \*\*options):

C:\ProgramData\Anaconda2\lib\site-packages\asana\client.pyc in request(self, method, path, \*\*options)  
83 url, auth=self.auth, \*\*request\_options)  
84 if response.status\_code in STATUS\_MAP:  
—\> 85 raise STATUS\_MAPresponse.status\_code  
86 elif 500 \<= response.status\_code \< 600:  
87 # Any unhandled 500 is a server error.

**ForbiddenError: Forbidden: You can only request portfolios that you own.**

=====================================

Either way, I can’t loop through user\_id to get a list of all portfolios. Is the API when getting a list of projects only getting public within my workspace then? Why are portfolio’s considered private when I can get so much project and task data? Can I set portfolios to be owned by everyone?

**ASK: How could I make a portfolio public within my workspace? Or does a portfolio HAVE to be owned by an account? Is this on the product timeline to have portfolios better integrated with the Asana platform. You have to invite people by a link anyway which is outside of the normal workflow for projects and tasks**

I would be greatly thankful for any advise on these asks.

All the best,  
Jake

---

<div class="post-metadata">

**Author:** ![Mahmudul\_Hasan](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/mahmudul_hasan/32/29714_2.png) [@Mahmudul\_Hasan](https://forum.asana.com/u/Mahmudul_Hasan)\
**Post date:** [3 April 2019 18:34 UTC](https://forum.asana.com/t/python-api-getting-project-ids-from-portfolios-locked-out-of-other-portfolios/46340/2 "2019-04-03T18:34:10Z")

</div>

Hi [Jake\_Olsby](https://forum.asana.com/u/Jake_Olsby),

Welcome to the community!

Assuming you write and/or customize python code, the list of projects can be obtained via the [ITEMS IN A PORTFOLIO](https://asana.com/developers/api-reference/portfolios#items) endpoint where each item corresponds to project (compact form / less details) in a particular portfolio.

```auto
GET /portfolios/{portfolio_gid}/items

```

Then you can get more details of projects using

```auto
GET /projects/{project_gid}

```

You can follow similar methods available in the Python SDK for other endpoints.

There is no projects-\>portfolios mapping (I haven’t seen) in the API that could address portfolio to project relations except the above one. @Joe_Trollo, @Diakoptis could provide more insights, I believe.

#Regarding ASK 2:

According to the [Portfolios Endpoint](https://asana.com/developers/api-reference/portfolios#query), you are unable to retrieve portfolios owned by others (other Asana account holders). You can see all portfolios of all members of the workspace in the Asana account, but in order to retrieve all portfolios in your workspace via API you will need to use API keys from other account holders who are the owner of their portfolios.

Hope that gives you some insights.

---

<div class="post-metadata">

**Author:** ![Joe\_Trollo](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/joe_trollo/32/4025_2.png) [@Joe\_Trollo](https://forum.asana.com/u/Joe_Trollo)\
**Post date:** [8 April 2019 20:33 UTC](https://forum.asana.com/t/python-api-getting-project-ids-from-portfolios-locked-out-of-other-portfolios/46340/3 "2019-04-08T20:33:51Z")

</div>

Hi @Jake_Olsby, sorry about the missing method in our client libraries—they tend to lag behind our official API due to the process involved in updating them with new features.

Unfortunately, we do not currently expose any mapping from a project to the portfolios it’s in—only from a portfolio to the projects it contains. Additionally, portfolios cannot be made public and must have an owner. This is a limitation of the web product that the API cannot avoid, but we will update the API as soon as we hear of changes to portfolios in the web product.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/asana/user_avatar/forum.asana.com/system/32/276370_2.png) [@system](https://forum.asana.com/u/system)\
**Post date:** [30 May 2025 19:07 UTC](https://forum.asana.com/t/python-api-getting-project-ids-from-portfolios-locked-out-of-other-portfolios/46340/4 "2025-05-30T19:07:59Z")

</div>

Closed on 30 May 2025 19:07 UTC


