How to get sheet owner information
I am trying to get sheet owner information through python SDK.
But I am getting "None" for owner name.
Am I doing something wrong here?
Best Answer
-
Paul is correct. It looks like we now need to grab the sheet shares to get the owner information.
Here is a python function that will get the owner of a sheet by sheet ID:
def get_owner_from_shares(sheetId): # exclude workspace shares so we don't get the owner of the workspace response = smartSheetClient.Sheets.list_shares( sheetId, include_all=True, include_workspace_shares=False ) data = response.to_dict() owner = None for item in data["result"]: if item.get("accessLevel") == "OWNER": owner = item break return owner
I have been trying to track changes in the Smartsheet API, but I missed this change. I am pretty sure that this get sheet call used to return the owner information up to sometime in December.
While Smartsheet updates their API documentation, they do not tell you what changed in the documentation. Which is a MAJOR pain point for developers. (I discussed this with them at the last conference.)
Answers
-
I am writing this quickly as I am about to leave the office. Hopefully, it will get you on track. I can dig deeper tomorrow. Hopefully, I am not incorrectly remembering this issue. I know ran into something like this last year.
I believe this is an undocumented change in the API wheresheet.owner
now returnsNone
You will have to take the
sheet.ownerId
from yourget_sheet
call and then make an API call togetUser
and provided the ownerId. Then you should be provided the email address. -
Hi Lee,
Thanks for your reply.Unfortunately,
sheet.owner_id
also gives me "None" in this case.Any advice?
-
If the get_sheet doesn't work for at least retrieving the owner, getting the sheet shares should do the trick.
-
Would you mind sharing the code?
-
Paul is correct. It looks like we now need to grab the sheet shares to get the owner information.
Here is a python function that will get the owner of a sheet by sheet ID:
def get_owner_from_shares(sheetId): # exclude workspace shares so we don't get the owner of the workspace response = smartSheetClient.Sheets.list_shares( sheetId, include_all=True, include_workspace_shares=False ) data = response.to_dict() owner = None for item in data["result"]: if item.get("accessLevel") == "OWNER": owner = item break return owner
I have been trying to track changes in the Smartsheet API, but I missed this change. I am pretty sure that this get sheet call used to return the owner information up to sometime in December.
While Smartsheet updates their API documentation, they do not tell you what changed in the documentation. Which is a MAJOR pain point for developers. (I discussed this with them at the last conference.)
-
Sorry for that last block of text with the OWNER user object. I accidentally pasted it in my comment, and the forum comment editor will not let me delete it. (I even dropped into the browsers inspector and tried to remove it from the DOM.)
… and I tried to edit it in Firefox, and was able to delete it.
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 65.8K Get Help
- 425 Global Discussions
- 146 Industry Talk
- 485 Announcements
- 5.1K Ideas & Feature Requests
- 86 Brandfolder
- 151 Just for fun
- 73 Community Job Board
- 496 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 306 Events
- 37 Webinars
- 7.3K Forum Archives