Smartsheet API Call

Options

Hello Team,

Please let me know the best way to make an API call from Smartsheet to request data from another tool and how to handle the response. I know I need to use a GET request to make the API, call but I am not sure how to handle the response in Smartsheet.

Many Thanks,

Best Answer

  • Ryan Kramer
    Ryan Kramer ✭✭✭✭✭
    Answer ✓
    Options

    So the best way to do this is to have a script run locally or hosted somewhere outside of Smartsheet.

    You can then have this script make the "GET" requests to the various sources and pull that information locally and then push that data via a "POST" request to another source or potentially Smartsheet.

    We do these types of integrations all the time for various clients.

    Hope that helps!

    Ryan

Answers

  • Ryan Kramer
    Ryan Kramer ✭✭✭✭✭
    Answer ✓
    Options

    So the best way to do this is to have a script run locally or hosted somewhere outside of Smartsheet.

    You can then have this script make the "GET" requests to the various sources and pull that information locally and then push that data via a "POST" request to another source or potentially Smartsheet.

    We do these types of integrations all the time for various clients.

    Hope that helps!

    Ryan

  • Emskie321
    Options

    @Ryan Kramer

    Thanks for the response.

    This does help, much appreciated.

  • Ryan Kramer
    Ryan Kramer ✭✭✭✭✭
    Options

    @Emskie321 ,

    Glad to hear it!

    Let me know if you get stuck.

    Ryan

  • Emskie321
    Options

    @Ryan Kramer

    Hi Ryan,

    I am looking for some examples of a script, which uses the POST method to update specific columns in Smartsheet.

    Many Thanks.

  • Ryan Kramer
    Ryan Kramer ✭✭✭✭✭
    Options

    @Emskie321 ,

    So an update is usually a PUT request and not a POST request.

    And I see their API follows that pattern in the cURL implementation.

    curl https://api.smartsheet.com/2.0/sheets/{sheetId}/rows \

    -H "Authorization: Bearer JKlMNOpQ12RStUVwxYZAbcde3F5g6hijklM789" \

    -H "Content-Type: application/json" \

    -X PUT \

    -d '[{"id": "6572427401553796", "cells": [{"columnId": 7518312134403972,"image": {"altText": "New Alt Text"},"value": "new value"}, {"columnId": 1888812600190852,"value": "A"}]}, {"id": "2068827774183300", "cells": [{"columnId": 7518312134403972,"value": "desc_updated"}, {"columnId": 1888812600190852,"value": "B"}, {"columnId": 6552023773538180,"objectValue": {"objectType": "MULTI_CONTACT","values": [{"objectType": "CONTACT","email" : "john.doe@smartsheet.com","name": "John Doe"}, {"objectType": "CONTACT","email": "jane.roe@smartsheet.com","name": "Jane Roe"}]}}]}]'

    I generally prefer to use the respective SDK of my environment though. For me its almost always python -

    # Build new cell value

    new_cell = smartsheet.models.Cell()

    new_cell.column_id = 7036894123976580

    new_cell.value = "new value"

    new_cell.strict = False

     

    # Build the row to update

    new_row = smartsheet.models.Row()

    new_row.id = 6809535313667972

    new_row.cells.append(new_cell)


    # Update rows

    updated_row = smartsheet_client.Sheets.update_rows(

     2068827774183300,   # sheet_id

     [new_row])


    Ryan

    Did my post(s) help or answer your question or solve your problem? Please support the Community by marking it Insightful/Vote Up, Awesome, or/and as the accepted answer. It will make it easier for others to find a solution or help to answer!

  • Emskie321
    Options

    @Ryan Kramer

    Hi Ryan,

    Thank you so much for confirming the Method to use and the examples provided.

    They have helped me to get started with the API, I have been testing in Postman and it's going great!!

    Just one last question, are you aware of any limitations in the number of cells that can be updated with the API at one time. I will be updating about 350 cells on a weekly basis.

    Many thanks,

  • Ryan Kramer
    Ryan Kramer ✭✭✭✭✭
    Options

    @Emskie321 ,

    So I haven't had any cell limit per se since I normally look at these updates by rows and generally 500 rows at a time doesn't have issues for me.

    I've built a lot of processes that read from external sources or other sheets and aggregates to make updates and generally as long as I stay under this limit, it doesn't have any issues. When I go over it, sometimes the calls will fail.

    Ryan

    Did my post(s) help or answer your question or solve your problem? Please support the Community by marking it Insightful/Vote Up, Awesome, or/and as the accepted answer. It will make it easier for others to find a solution or help to answer!