Get a sheet URL with the Sheet ID [API]
I'm using Python and I want to get the URL of a sheet if I know its sheet ID.
I try to create a list of hyperlink thru the API.
I already have access to the sheet and I could copy the url by hand, but that is not the point.
Best Answer
-
Try this:
import smartsheet
# Set your Smartsheet API access token
access_token = 'YOUR_ACCESS_TOKEN'
# Set the sheet ID for which you want to retrieve the URL
sheet_id = 'YOUR_SHEET_ID'
# Initialize the Smartsheet client
client = smartsheet.Smartsheet(access_token)
# Get the sheet details using the sheet ID
sheet = client.Sheets.get_sheet(sheet_id)
# Retrieve the URL from the sheet details
sheet_url = sheet.permalink
print(f'The URL of the sheet is: {sheet_url}')
Answers
-
Try this:
import smartsheet
# Set your Smartsheet API access token
access_token = 'YOUR_ACCESS_TOKEN'
# Set the sheet ID for which you want to retrieve the URL
sheet_id = 'YOUR_SHEET_ID'
# Initialize the Smartsheet client
client = smartsheet.Smartsheet(access_token)
# Get the sheet details using the sheet ID
sheet = client.Sheets.get_sheet(sheet_id)
# Retrieve the URL from the sheet details
sheet_url = sheet.permalink
print(f'The URL of the sheet is: {sheet_url}')
-
Great !
I don't know why I,ve not seen this.
-
Anyone know how to do this the other way around? I have the sheet links, need the sheet ID. Looking to update sharing to a new group for these sheets via API
-
Off the top of my head, I think you would need to fetch a listing of all of your sheets, this should give you the Sheet Id and the permalink
https://smartsheet.redoc.ly/tag/sheets#operation/list-sheets
-
This last line is giving me an error
print(f'The URL of the sheet is: {sheet_url}')
The following error occurred:Unknown statement: print(f'The URL of the sheet is: {app.smartsheet.com/sheets/F368JG58Fmvh8j3j2Q9MMW5vxxW68WvfRM4G5hC1}')///$tab Auto-generated section
Categories
- All Categories
- 14 Welcome to the Community
- Smartsheet Customer Resources
- 64.1K Get Help
- 412 Global Discussions
- 221 Industry Talk
- 459 Announcements
- 4.8K Ideas & Feature Requests
- 143 Brandfolder
- 141 Just for fun
- 58 Community Job Board
- 461 Show & Tell
- 31 Member Spotlight
- 1 SmartStories
- 299 Events
- 38 Webinars
- 7.3K Forum Archives