What's the easiest way to grab all specific JSON data from a Smartsheet JSON?

I have a sheet that I have imported. I have a column that I'm trying to grab all the values from and add them to a list in Python what would be the easiest way to go about this from the development end?

Best Answer

  • Jeff Reisman
    Jeff Reisman ✭✭✭✭✭✭
    Answer ✓
    Hello Jeff & Shark,<\/p>
    However, when I try to do,\n https:\/\/api.smartsheet.com\/2.0\/sheets\/{sheetId}\/columns\n<\/pre>

    I get this:<\/p>

    {<\/p>

        "errorCode": 1006,<\/p>

        "message": "Not Found",<\/p>

        "refId": "6liwku"<\/p>

    }<\/p>

    I can get the sheet but not the columns?<\/p>","bodyRaw":"[{\"insert\":\"Hello Jeff & Shark,\\nHowever, when I try to do,\"},{\"attributes\":{\"code-block\":true},\"insert\":\"\\n\"},{\"insert\":\" https:\\\/\\\/api.smartsheet.com\\\/2.0\\\/sheets\\\/{sheetId}\\\/columns\"},{\"attributes\":{\"code-block\":true},\"insert\":\"\\n\"},{\"insert\":\"I get this:\\n{\\n    \\\"errorCode\\\": 1006,\\n    \\\"message\\\": \\\"Not Found\\\",\\n    \\\"refId\\\": \\\"6liwku\\\"\\n}\\n\\nI can get the sheet but not the columns?\\n\"}]","format":"rich","dateInserted":"2023-02-23T16:16:18+00:00","insertUser":{"userID":158634,"name":"DougSmartsheetDev","url":"https:\/\/community.smartsheet.com\/profile\/DougSmartsheetDev","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-02-28T14:04:06+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"displayOptions":{"showUserLabel":false,"showCompactUserInfo":true,"showDiscussionLink":false,"showPostLink":false,"showCategoryLink":false,"renderFullContent":false,"expandByDefault":false},"url":"https:\/\/community.smartsheet.com\/discussion\/comment\/363938#Comment_363938","embedType":"quote"}"> https://community.smartsheet.com/discussion/comment/363938#Comment_363938

    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:

    image.png


    image.png


    Regards,

    Jeff Reisman,IT Business Analyst & Project Coordinator,Mitsubishi Electric Trane US

    链接:Smartsheet Functions Help Pages链接: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

  • sharkasits
    sharkasits ✭✭✭✭

    @DougSmartsheetDevI 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 athttps://api.smartsheet.com/2.0/sheets/<> 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.<>.title

    Once you know the column index, all the values for that column will be in the JSON element

    rows.<>.cells.<>.value

    Sorry I can't help with the specific Python, but I hope that helps.

  • Jeff Reisman
    Jeff Reisman ✭✭✭✭✭✭

    @DougSmartsheetDev

    Start with theSmartsheet 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 theSmartsheet Live Data Connectorto query the sheet you want and use some other app to parse the column data to json.

    Regards,

    Jeff Reisman,IT Business Analyst & Project Coordinator,Mitsubishi Electric Trane US

    链接:Smartsheet Functions Help Pages链接: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!

  • DougSmartsheetDev
    edited 02/23/23

    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?

  • Jeff Reisman
    Jeff Reisman ✭✭✭✭✭✭
    Answer ✓
    Hello Jeff & Shark,<\/p>
    However, when I try to do,\n https:\/\/api.smartsheet.com\/2.0\/sheets\/{sheetId}\/columns\n<\/pre>

    I get this:<\/p>

    {<\/p>

        "errorCode": 1006,<\/p>

        "message": "Not Found",<\/p>

        "refId": "6liwku"<\/p>

    }<\/p>

    I can get the sheet but not the columns?<\/p>","bodyRaw":"[{\"insert\":\"Hello Jeff & Shark,\\nHowever, when I try to do,\"},{\"attributes\":{\"code-block\":true},\"insert\":\"\\n\"},{\"insert\":\" https:\\\/\\\/api.smartsheet.com\\\/2.0\\\/sheets\\\/{sheetId}\\\/columns\"},{\"attributes\":{\"code-block\":true},\"insert\":\"\\n\"},{\"insert\":\"I get this:\\n{\\n    \\\"errorCode\\\": 1006,\\n    \\\"message\\\": \\\"Not Found\\\",\\n    \\\"refId\\\": \\\"6liwku\\\"\\n}\\n\\nI can get the sheet but not the columns?\\n\"}]","format":"rich","dateInserted":"2023-02-23T16:16:18+00:00","insertUser":{"userID":158634,"name":"DougSmartsheetDev","url":"https:\/\/community.smartsheet.com\/profile\/DougSmartsheetDev","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-02-28T14:04:06+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"displayOptions":{"showUserLabel":false,"showCompactUserInfo":true,"showDiscussionLink":false,"showPostLink":false,"showCategoryLink":false,"renderFullContent":false,"expandByDefault":false},"url":"https:\/\/community.smartsheet.com\/discussion\/comment\/363938#Comment_363938","embedType":"quote"}"> https://community.smartsheet.com/discussion/comment/363938#Comment_363938

    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:

    image.png


    image.png


    Regards,

    Jeff Reisman,IT Business Analyst & Project Coordinator,Mitsubishi Electric Trane US

    链接:Smartsheet Functions Help Pages链接: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

  • Jeff Reisman
    Jeff Reisman ✭✭✭✭✭✭

    @DougSmartsheetDev

    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,IT Business Analyst & Project Coordinator,Mitsubishi Electric Trane US

    链接:Smartsheet Functions Help Pages链接: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!

  • DougSmartsheetDev
    edited 02/23/23

    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.

Feel free to submit a Product Idea!<\/p>

There's nothing we can do as users. It would require a rebuild of that system. I'm pretty sure it's resource intensive, and runs on a schedule performing the automations.<\/p>"},{"commentID":388346,"body":"

No problem. Sorry I didn't have a way to help solve your problem. <\/p>

Having to wait is especially frustrating for me when I'm giving a demo, but that's not the only time I'd like them to execute faster. <\/p>

Consider submitting a Product Idea here (if a search for an already made suggestion isn't available for you to upvote. <\/p>

\n \n https:\/\/community.smartsheet.com\/post\/idea\n <\/a>\n<\/div>

All the best,<\/p>

-Ray<\/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":[]},{"discussionID":107839,"type":"question","name":"Extract List of Unique Values","excerpt":"Hi Is it possible to use Bridge to extract from a column a list of values, run a JS to extract an array of unique values, and then pass this to another sheet and update another column with this unique list?","snippet":"Hi Is it possible to use Bridge to extract from a column a list of values, run a JS to extract an array of unique values, and then pass this to another sheet and update another…","categoryID":320,"dateInserted":"2023-07-20T06:57:54+00:00","dateUpdated":"2023-07-20T07:09:25+00:00","dateLastComment":"2023-07-23T23:46:17+00:00","insertUserID":125212,"insertUser":{"userID":125212,"name":"Neil Watson","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Neil%20Watson","photoUrl":"https:\/\/aws.smartsheet.com\/storageProxy\/image\/images\/u!1!pglbKXXltro!HIFbX6W_ivo!Lnqe5-nvNY5","dateLastActive":"2023-08-09T07:48:38+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"updateUserID":125212,"lastUserID":45516,"lastUser":{"userID":45516,"name":"Paul Newcome","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Paul%20Newcome","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/082\/nQPUTVFKKWDJ2.jpg","dateLastActive":"2023-08-10T16:10:59+00:00","banned":0,"punished":0,"private":false,"label":"✭✭✭✭✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":8,"countViews":132,"score":null,"hot":3379997051,"url":"https:\/\/community.smartsheet.com\/discussion\/107839\/extract-list-of-unique-values","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/107839\/extract-list-of-unique-values","format":"Rich","tagIDs":[369],"lastPost":{"discussionID":107839,"commentID":386578,"name":"Re: Extract List of Unique Values","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/386578#Comment_386578","dateInserted":"2023-07-23T23:46:17+00:00","insertUserID":45516,"insertUser":{"userID":45516,"name":"Paul Newcome","title":"","url":"https:\/\/community.smartsheet.com\/profile\/Paul%20Newcome","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/082\/nQPUTVFKKWDJ2.jpg","dateLastActive":"2023-08-10T16:10:59+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-07-23T08:22:10+00:00","dateAnswered":"2023-07-21T12:06:06+00:00","acceptedAnswers":[{"commentID":386363,"body":"

@Neil Watson<\/a> You should be able to use the LOWER function for evaluation but still output the version that includes caps.<\/p>

=IFERROR(INDEX(DISTINCT(LOWER(<\/strong>COLLECT(.....................))<\/strong>), 1), \"//www.santa-greenland.com/community/discussion/comment/\")<\/p>


<\/p>

I haven't tested it yet, but I feel like it should work.<\/p>"},{"commentID":386435,"body":"

Right. There are already a number of posts here in the community detailing how to pull a distinct or unique list from another sheet via formula. It usually involves the formula above without the LOWER function. The number 1 would output the first distinct value. Changing that to a 2 will output the second distinct value, so on and so forth. I usually use a helper column with the numbers manually entered so I can apply it as a column formula.<\/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":369,"urlcode":"bridge-by-smartsheet","name":"Bridge"}]},{"discussionID":107219,"type":"question","name":"How to use access_token? (api.smartsheet.com\/2.0\/token)","excerpt":"Node.js How to use access_token? I'm making a request: axios.post('https:\/\/api.smartsheet.com\/2.0\/token')... response: { access_token: 'xxx', token_type: 'bearer', refresh_token: 'xxx', expires_in: 604799 } var smartsheet = client.createClient({ accessToken: 'xxx', logLevel: 'info', }); But the result is always the same:…","snippet":"Node.js How to use access_token? I'm making a request: axios.post('https:\/\/api.smartsheet.com\/2.0\/token')... response: { access_token: 'xxx', token_type: 'bearer', refresh_token:…","categoryID":320,"dateInserted":"2023-07-05T05:43:29+00:00","dateUpdated":"2023-07-05T09:15:26+00:00","dateLastComment":"2023-08-07T12:06:57+00:00","insertUserID":163125,"insertUser":{"userID":163125,"name":"Bortyk","url":"https:\/\/community.smartsheet.com\/profile\/Bortyk","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-08-09T05:34:14+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":91566,"lastUserID":91566,"lastUser":{"userID":91566,"name":"Genevieve P.","title":"Community Manager","url":"https:\/\/community.smartsheet.com\/profile\/Genevieve%20P.","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/KHY4Y67W0VRX\/nF76D5N9MFB28.png","dateLastActive":"2023-08-10T16:36:40+00:00","banned":0,"punished":0,"private":false,"label":"Employee Admin"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":4,"countViews":132,"score":null,"hot":3379948226,"url":"https:\/\/community.smartsheet.com\/discussion\/107219\/how-to-use-access-token-api-smartsheet-com-2-0-token","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/107219\/how-to-use-access-token-api-smartsheet-com-2-0-token","format":"Rich","lastPost":{"discussionID":107219,"commentID":389163,"name":"Re: How to use access_token? (api.smartsheet.com\/2.0\/token)","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/389163#Comment_389163","dateInserted":"2023-08-07T12:06:57+00:00","insertUserID":91566,"insertUser":{"userID":91566,"name":"Genevieve P.","title":"Community Manager","url":"https:\/\/community.smartsheet.com\/profile\/Genevieve%20P.","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/userpics\/KHY4Y67W0VRX\/nF76D5N9MFB28.png","dateLastActive":"2023-08-10T16:36:40+00:00","banned":0,"punished":0,"private":false,"label":"Employee Admin"}},"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-08-09T01:57:51+00:00","dateAnswered":"2023-08-07T12:06:57+00:00","acceptedAnswers":[{"commentID":389163,"body":"

Hey @Bortyk<\/a> <\/p>

An Access Token will only provide you with the same permissions and access that the account has in the Smartsheet UI. <\/p>

For example, if you're trying to Edit a sheet through the API, you'll need to have at least Editor permissions on that sheet in the UI. <\/p>

I would suggest making sure that the account you're using to access the API has the correct permissions on each item and also in the account as well (e.g. if it needs to be a System Admin for the plan or not).<\/p>

Cheers,<\/p>

Genevieve<\/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":[]}],"initialPaging":{"nextURL":"https:\/\/community.smartsheet.com\/api\/v2\/discussions?page=2&categoryID=320&includeChildCategories=1&type%5B0%5D=Question&excludeHiddenCategories=1&sort=-hot&limit=3&expand%5B0%5D=all&expand%5B1%5D=-body&expand%5B2%5D=insertUser&expand%5B3%5D=lastUser&status=accepted","prevURL":null,"currentPage":1,"total":209,"limit":3},"title":"Trending in API & Developers","subtitle":null,"description":null,"noCheckboxes":true,"containerOptions":[],"discussionOptions":[]}">

Trending in API & Developers