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.
- 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:
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 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.
- 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)
12 , color
13 , workspace
—> 14 ’
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)
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,