Closed evildani closed 7 months ago
Hi @evildani,
If I am understanding your problem correctly, it looks like you are trying to add a project to a specific portfolio on project creation. This is not possible with our Create a project API endpoint. You can however, add an existing/already created project to a portfolio. To do so, use the Add a portfolio item endpoint. Here's the python method for this API add_item_for_portfolio.
Here's a template for that request:
import asana
from asana.rest import ApiException
from pprint import pprint
configuration = asana.Configuration()
configuration.access_token = '<YOUR_ACCESS_TOKEN>'
api_client = asana.ApiClient(configuration)
portfolios_api_instance = asana.PortfoliosApi(api_client)
body = {"data": {"item": "<YOUR_PROJECT_GID>", }}
portfolio_gid = "<YOUR_PORTFOLIO_GID>"
try:
# Add a portfolio item
api_response = portfolios_api_instance.add_item_for_portfolio(body, portfolio_gid)
pprint(api_response)
except ApiException as e:
print("Exception when calling PortfoliosApi->add_item_for_portfolio: %s\n" % e)
I have been trying to join a (duplicated) project (with all tasks contained) to join into a new portfolio that is created in just before the project is created. But I haven been able to figure out the relationship between portfolio and a project in the API. In the Web GUI is pretty forward, you add it. I have tried: When creating the project to specify the portfolio Add the membership into both the project or the portfolio
I am sure this is possible, I just missing the underlying relationship between the two.
Please help?