What's the easiest way to grab all specific JSON data from a Smartsheet JSON?
Best Answer
-
Are you putting the sheetId value in place of {sheetId} ?
When I run that as a GET in Postman, I get an array of each column ID with the name and type:
Regards,
Jeff Reisman
Link: Smartsheet Functions Help Pages Link: Smartsheet Formula Error Messages
If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!
Answers
-
@DougSmartsheetDev I don't use Python for this, so I can't give you specifics on that, bur from the API side you'll use a GET at https://api.smartsheet.com/2.0/sheets/<<sheet id>> to pull the data.
If you don't know the column index you can look for the column title where the JSON element is
columns.<<column index>>.title
Once you know the column index, all the values for that column will be in the JSON element
rows.<<row id>>.cells.<<column index>>.value
Sorry I can't help with the specific Python, but I hope that helps.
-
Start with the Smartsheet API 2.0 / SDK guide.
First, get your API Auth Bearer Token from the admin app.
Then you need to isolate your sheet id:
GET /sheets https://api.smartsheet.com/2.0/sheets response = smartsheet_client.Sheets.list_sheets(include_all=True) sheets = response.data Response sample: { "pageNumber": 1, "pageSize": 50, "totalPages": 25, "totalCount": 136, "data": [ { "id": 0, "accessLevel": "ADMIN", "createdAt": "2019-08-24T14:15:22Z", "modifiedAt": "2019-08-24T14:15:22Z", "name": "string", "permalink": "string", "version": 0, "source": { "id": 0, "type": "string" } } ] }
Then you need to GET the list of columns and find the column Id you're looking for:
https://api.smartsheet.com/2.0/sheets/{sheetId}/columns response = smartsheet_client.Sheets.get_columns( 9283173393803140, # sheet_id include_all=True) columns = response.data Sample Response: { "pageNumber": 1, "pageSize": 50, "totalPages": 25, "totalCount": 136, "data": [ { "id": 0, "index": 0, "symbol": "string", "title": "string", "type": "ABSTRACT_DATETIME", "validation": true } ] }
Then you need to GET the row data from that column:
That's detailed here in the API/SDK guide: https://smartsheet.redoc.ly/tag/rows#operation/row-get
You could also use the Smartsheet Live Data Connector to query the sheet you want and use some other app to parse the column data to json.
Regards,
Jeff Reisman
Link: Smartsheet Functions Help Pages Link: Smartsheet Formula Error Messages
If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!
-
Really appreciate all the help. Super awesome of everybody.
Gratefully,
Doug
-
Hello Jeff & Shark,
However, when I try to do, https://api.smartsheet.com/2.0/sheets/{sheetId}/columns
I get this:
{
"errorCode": 1006,
"message": "Not Found",
"refId": "6liwku"
}
I can get the sheet but not the columns?
-
Are you putting the sheetId value in place of {sheetId} ?
When I run that as a GET in Postman, I get an array of each column ID with the name and type:
Regards,
Jeff Reisman
Link: Smartsheet Functions Help Pages Link: Smartsheet Formula Error Messages
If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!
-
Jeff,
Appreciate the response!
Yes I am putting the sheetId in place there. I'm able to access the sheet it's when I try to access anything further that I have trouble.
Thankfully,
Doug
-
Do you have at least editor permissions on the sheet you're trying to pull from? I don't believe your API token can access anything that your account cannot.
Double check that the sheet ID is correct.
I'm assuming you're not using { } curly braces in the URL.
Before the sheet ID, "sheets" should be all lowercase, as should "columns" after the Sheet ID.
Any of the above being wrong will throw an error code 1006 "Not Found".
Regards,
Jeff Reisman
Link: Smartsheet Functions Help Pages Link: Smartsheet Formula Error Messages
If my answer helped solve your issue, please mark it as accepted so that other users can find it later. Thanks!
-
Jeff,
- No curly Braces in URL
- sheets is lowercase, get call works for sheet, just stops at the /columns
- sheetId is correct
- Permission level is admin
indebtedly,
Doug
Edit: Embarrassed to say that I had my sheet ID & Linked Values Swapped. The answers provided above worked like a charm. My bad all and thank you.
Categories
- All Categories
- 14 Welcome to the Community
- Customer Resources
- 64.9K Get Help
- 441 Global Discussions
- 139 Industry Talk
- 471 Announcements
- 4.9K Ideas & Feature Requests
- 129 Brandfolder
- 148 Just for fun
- 68 Community Job Board
- 495 Show & Tell
- 33 Member Spotlight
- 2 SmartStories
- 300 Events
- 36 Webinars
- 7.3K Forum Archives