Welcome to the Smartsheet Forum Archives


The posts in this forum are no longer monitored for accuracy and their content may no longer be current. If there's a discussion here that interests you and you'd like to find (or create) a more current version, please Visit the Current Forums.

Download Sheet data via API

Juan Montoya
edited 12/09/19 in Archived 2016 Posts

Is there sample code in C# to download data from a sheet to a local drive?

 

for some reason when I use the API and try to read the number of rows I always get null values

 

long? numRows = tmpSheet.TotalRowCount;

 

Thanks in advance

Comments

  • Hi Juan!

     

    We have some basic code samples available in our API documentation. If you're looking to download a Sheet onto your local computer, I'd suggest looking at this section in our docs: http://smartsheet-platform.github.io/api-docs/?csharp#get-sheet-as-excel-/-pdf-/-csv

     

    We also have SDKs available in C#, which may help you to get started with the API. You can download them here: https://www.smartsheet.com/developers/sdks

     

    I hope this helps!

     

    Cheers,

    Joseph

  • CORREIOS SMARTSHEET
    edited 10/10/16

    Same problem. this is my code in pYthon 2.7, Debian OS, with ordinary user credentials. Tokens were substituted for security reasons.

     

    OBJECUTVE: Read a certain SmartSheet, read thru its collumns and row and get some data, using API.

     

    Please find below my code:

     

    # -*- coding: utf-8 -*-
    #!/usr/bin/python

    import smartsheet

    #Token
    planilha = smartsheet.Smartsheet(MyToken)

    #SheetId
    xSheetId = MySheetId

    #print Sheet
    print 'Getting sheet %s' % (xSheetId)

    # Get sheet
    xSheet = planilha.Sheets.get_sheet(xSheetId)

    # print result
    print xSheet

     

    When I run the above code, I get the following errors.

    ...

    Getting sheet MyToken
    Traceback (most recent call last):
      File "gestao6.py", line 16, in <module>
        xSheet = planilha.Sheets.get_sheet(xSheetId)
      File "/usr/local/lib/python2.7/dist-packages/smartsheet/sheets.py", line 460, in get_sheet
        response = self._base.request(prepped_request, expected, _op)
      File "/usr/local/lib/python2.7/dist-packages/smartsheet/smartsheet.py", line 179, in request
        native = res.native(expected)
      File "/usr/local/lib/python2.7/dist-packages/smartsheet/smartsheet.py", line 408, in native
        obj = class_(data, self._base)
      File "/usr/local/lib/python2.7/dist-packages/smartsheet/models/sheet.py", line 90, in __init__
        self.columns = props['columns']
      File "/usr/local/lib/python2.7/dist-packages/smartsheet/models/sheet.py", line 220, in columns
        if not isinstance(x, Column) else x) for x in value
      File "/usr/local/lib/python2.7/dist-packages/smartsheet/models/column.py", line 134, in __init__
        self.options = props['options']
      File "/usr/local/lib/python2.7/dist-packages/smartsheet/models/column.py", line 257, in options
        if not isinstance(x, str) else x) for x in value
    UnicodeEncodeError: 'ascii' codec can't encode character u'\xda' in position 6: ordinal not in range(128)

     

    If I run with Curl, with the same credentials

    curl https://api.smartsheet.com/2.0/sheets/xSheetId -H "Authorization: MyToken"

     

    I get the following error:

     

    {
      "errorCode" : 1004,
      "message" : "You are not authorized to perform this action.",
      "refId" : "1lym35mqns1bx"
    }

     

    Any clues?

This discussion has been closed.