get_portfolios api results - python

Hi Dev Community,

I am trying to create a porfolio report across my team of Program Managers (8 members). When I use the client.portfolios.get_portfolios() and I try to print the result i get <generator object PageIterator.items at 0x0000019D7F48EE40>.

How do I get the output in a JSON format ?

hi @Ken_Harrison
I am also trying it
@Ken_Harrison if you can find the solution to this plz dm me
thanks

Hey Johan,

The get_portfolios function works as intended. To get the results you need to add the result to a list()

`python

get_portfolios = client.portfolios.get_portfolios({‘workspace’:‘’, ‘owner’: ‘’}, opt_pretty=True)

print(list(get_portfolios))

`

1 Like

Hey Johan,

The get_portfolios function works as intended. To get the results you need to add the result to a list()

get_portfolios = client.portfolios.get_portfolios({‘workspace’:'{your workspace}', ‘owner’: ‘{your gid}', opt_pretty=True)`

print(list(get_portfolios)) # by using list()
print([x for x in get_portfolios] # by using list comprehension

1 Like