I am trying to set or update the owner of a Portfolio that is being created by the API, but I cannot figure out how to do it. I have successfully used the create and update portfolio endpoints without setting the owner.
I have tried passing the user gid and the full object from the get user API and nothing seems to work. I get a 400 response with the message that “owner” cannot be written.
There must be a way to do this, right? Any help would be greatly appreciated.
I don’t think that’s possible; I think the key is in the text I highlighted in bold italics below, from the API docs:
Get multiple portfolios
Returns a list of the portfolios in compact representation that are owned by the current API user.
In other words, you only have access to those portfolios you own; so it would not make sense for you to be able to modify a portfolio such that it goes outside of that restriction.
@John_Vu@Andrew-asana maybe you can confirm or correct my reasoning? Is it true a portfolio owner can’t be changed in the API?
Perhaps I am barking up the wrong tree here. All I care about is giving the end users that need admin access to the portfolios/project the right permissions. It looks like there is a different method for adding and removing members which should accomplish that. I can set up a bot account for creating the records so there is no ambiguity around ownership.
Yes, given that’s your end goal, I think that’s exactly right. I think the “owner” per se is not really relevant or meaningful; the key is setting up the admin membership access the way you want it.
I am having trouble setting user level on the portfolio though. When I post to the https://app.asana.com/api/1.0/portfolios/{portfolio_gid}/addMembers endpoint with the Python SDK method .add_members_for_portfolio, I can add a member using the GID, but I cannot seem to set their administrative level.
I have found that the API ignores any key-value pair that is not “members”. I can’t even get the server to send a 400 response if the members field is included correctly. The method always adds the user at the default level permissions set on the portfolio.
Any thoughts on what needs to happen to resolve this? I cannot find any examples of the API sending a body with this data, so I feel like I am shooting in the dark here.
I found what I was looking for. There is a memberships endpoint and a portfolio memberships endpoint. Seems like memberships is the new and improved way to accomplish this. This was pretty confusing for someone that was just getting started with the API.
Also, the Python SDK includes the body of the api call in the opts parameter, which is different than other parts of the SDK.