D列表iscussions function limited characters
Hello,
I am trying to pull all discussion and comments associated with a sheet ID.
I was able to pull using the API through python as shown below.
However the comments came in with only limited characters, in other words I can only see the first 100 characters. Please advice
PYTHON代码如下
"
import smartsheet
import pandas as pd
#Set the Access Token
SMARTSHEET_ACCESS_TOKEN = "xxxxxxxx"
# Initialize client
smartsheet_client = smartsheet.Smartsheet(SMARTSHEET_ACCESS_TOKEN)
#Set the Sheet_id
sheet_id = xxxxxxxx
sheet = smartsheet_client.Sheets.get_sheet(sheet_id)
print("Loaded Sheet: " + sheet.name)
#Call the discussions for the specified sheet
response = smartsheet_client.Discussions.get_all_discussions(sheet_id,include_all=True)
discussions = response.data
#Transform the discussion data to dictionary format
discussionsDict = response.to_dict()
#Create a comments dataframe from the discussion dictionary
commentsdf = pd.DataFrame.from_dict(discussionsDict['data'])
#Save the comments dataframe to a csv file
commentsdf.to_csv('comments.csv')
"
Best Answer
-
Hi@telduzdar,
I think that instead of the comment, you are seeing the discussion title, which is created by "duplicating the first 100 characters of top-level comment." (https://smartsheet.redoc.ly/#operation/discussions-list, response, data, title)
To include the comments to the data response, you should addinclude = 'comments'to your call:
response = smartsheet_client.Discussions.get_all_discussions(sheet_id,include_all=True, include='comments')
Hope that helps!
Answers
-
Hi@telduzdar,
I think that instead of the comment, you are seeing the discussion title, which is created by "duplicating the first 100 characters of top-level comment." (https://smartsheet.redoc.ly/#operation/discussions-list, response, data, title)
To include the comments to the data response, you should addinclude = 'comments'to your call:
response = smartsheet_client.Discussions.get_all_discussions(sheet_id,include_all=True, include='comments')
Hope that helps!
-
Thanks a lot@JKrombeenASKthat parameter did it!
Much appreciated!
Categories
import smartsheet<\/p>
# Set your Smartsheet API access token<\/p>
access_token = 'YOUR_ACCESS_TOKEN'<\/p>
# Set the sheet ID for which you want to retrieve the URL<\/p>
sheet_id = 'YOUR_SHEET_ID'<\/p>
# Initialize the Smartsheet client<\/p>
client = smartsheet.Smartsheet(access_token)<\/p>
# Get the sheet details using the sheet ID<\/p>
sheet = client.Sheets.get_sheet(sheet_id)<\/p>
# Retrieve the URL from the sheet details<\/p>
sheet_url = sheet.permalink<\/p>
print(f'The URL of the sheet is: {sheet_url}')<\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":320,"name":"API & Developers","url":"https:\/\/community.smartsheet.com\/categories\/api-developers","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[{"tagID":563,"urlcode":"api","name":"API"}]},{"discussionID":106751,"type":"question","name":"Creating a Group via API","excerpt":"I've searched the API Documentation, as well as github and I'm not seeing anything that allows someone to create a Smartsheet Group via the API - is that possible and I'm just not looking at the right thing? We are trying to set up automation with a multi-tier solution, and have others who are submitting project requests…","snippet":"I've searched the API Documentation, as well as github and I'm not seeing anything that allows someone to create a Smartsheet Group via the API - is that possible and I'm just not…","categoryID":320,"dateInserted":"2023-06-22T02:44:29+00:00","dateUpdated":null,"dateLastComment":"2023-06-23T13:30:01+00:00","insertUserID":161991,"insertUser":{"userID":161991,"name":"isabonita","title":"Smartsheet Administrator","url":"https:\/\/community.smartsheet.com\/profile\/isabonita","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-06-24T23:32:02+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":null,"lastUserID":161991,"lastUser":{"userID":161991,"name":"isabonita","title":"Smartsheet Administrator","url":"https:\/\/community.smartsheet.com\/profile\/isabonita","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-06-24T23:32:02+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":2,"countViews":56,"score":null,"hot":3374930070,"url":"https:\/\/community.smartsheet.com\/discussion\/106751\/creating-a-group-via-api","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/106751\/creating-a-group-via-api","format":"Rich","tagIDs":[227,442],"lastPost":{"discussionID":106751,"commentID":381947,"name":"Re: Creating a Group via API","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/381947#Comment_381947","dateInserted":"2023-06-23T13:30:01+00:00","insertUserID":161991,"insertUser":{"userID":161991,"name":"isabonita","title":"Smartsheet Administrator","url":"https:\/\/community.smartsheet.com\/profile\/isabonita","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-06-24T23:32:02+00:00","banned":0,"punished":0,"private":false,"label":"✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"API & Developers","url":"https:\/\/community.smartsheet.com\/categories\/api-developers"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-06-23T13:29:35+00:00","dateAnswered":"2023-06-22T21:15:53+00:00","acceptedAnswers":[{"commentID":381854,"body":"
@isabonita<\/a> <\/p> See below link:<\/p> https:\/\/smartsheet.redoc.ly\/tag\/groups#operation\/add-group<\/a><\/p>"}]}},"status":{"statusID":3,"name":"Accepted","state":"closed","recordType":"discussion","recordSubType":"question"},"bookmarked":false,"unread":false,"category":{"categoryID":320,"name":"API & Developers","url":"https:\/\/community.smartsheet.com\/categories\/api-developers","allowedDiscussionTypes":[]},"reactions":[{"tagID":3,"urlcode":"Promote","name":"Promote","class":"Positive","hasReacted":false,"reactionValue":5,"count":0},{"tagID":5,"urlcode":"Insightful","name":"Insightful","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":11,"urlcode":"Up","name":"Vote Up","class":"Positive","hasReacted":false,"reactionValue":1,"count":0},{"tagID":13,"urlcode":"Awesome","name":"Awesome","class":"Positive","hasReacted":false,"reactionValue":1,"count":0}],"tags":[{"tagID":227,"urlcode":"api-and-developers","name":"API and Developers"},{"tagID":442,"urlcode":"groups-and-group-management","name":"Groups and Group Management"}]},{"discussionID":106741,"type":"question","name":"Using the API to get attachment URLs","excerpt":"I have PDF row attachments in a sheet. I need to get a direct URL to the attachment but I can't see a way to do this in the API. Using the GUI to \"send\" the file provides a link - so I'm trying to get something similar through the API. I'm aware that the the URL using the GUI method expires after 30 days. I would prefer…","snippet":"I have PDF row attachments in a sheet. I need to get a direct URL to the attachment but I can't see a way to do this in the API. Using the GUI to \"send\" the file provides a link -…","categoryID":320,"dateInserted":"2023-06-21T22:40:34+00:00","dateUpdated":null,"dateLastComment":"2023-06-22T20:21:40+00:00","insertUserID":150432,"insertUser":{"userID":150432,"name":"jzadra","url":"https:\/\/community.smartsheet.com\/profile\/jzadra","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-07-05T17:46:19+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":null,"lastUserID":150432,"lastUser":{"userID":150432,"name":"jzadra","url":"https:\/\/community.smartsheet.com\/profile\/jzadra","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-07-05T17:46:19+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":2,"countViews":50,"score":null,"hot":3374853734,"url":"https:\/\/community.smartsheet.com\/discussion\/106741\/using-the-api-to-get-attachment-urls","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/106741\/using-the-api-to-get-attachment-urls","format":"Rich","tagIDs":[227,268],"lastPost":{"discussionID":106741,"commentID":381846,"name":"Re: Using the API to get attachment URLs","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/381846#Comment_381846","dateInserted":"2023-06-22T20:21:40+00:00","insertUserID":150432,"insertUser":{"userID":150432,"name":"jzadra","url":"https:\/\/community.smartsheet.com\/profile\/jzadra","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-07-05T17:46:19+00:00","banned":0,"punished":0,"private":false,"label":"✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"Get Help","url":"https:\/\/community.smartsheet.com\/categories\/get-help"},{"name":"API & Developers","url":"https:\/\/community.smartsheet.com\/categories\/api-developers"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-06-22T20:20:13+00:00","dateAnswered":"2023-06-22T00:36:56+00:00","acceptedAnswers":[{"commentID":381653,"body":" You make a call to<\/p>