How to find a row ID or column ID in smartsheet?

寵の児 提交于 2019-12-22 12:41:07

问题


I've been working with and reading the smartsheet API for a few hours now and I notice that in all the requests I have to make, I will need either a row ID or a column ID. I must be missing something easy here, but where do I find these IDs? Are they found through a query or somewhere on the actual view-able sheet?

Currently I am trying create a json object to send to me sheet and this is the code I have:

MySS = smartsheet.Smartsheet('*****************')
headers = {"Authorization": "Bearer *****************", "Content-Type": 'application/json',
           "Accept": "application/json"}
row = MySS.Sheets.get_row(***********, HOW_DO_I_GET_THIS, include='discussions,attachments,columns,columnType')
r = requests.post("https://api.smartsheet.com/2.0/sheets/**********/rows", json=row, headers=headers)

The error message I get from this is :

Traceback (most recent call last):
  File "C:/Users/***/**/**/**/***", line 89, in <module>
    headers=headers)
  File "C:\Python27\lib\site-packages\requests\api.py", line 111, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "C:\Python27\lib\site-packages\requests\api.py", line 57, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Python27\lib\site-packages\requests\sessions.py", line 585, in send
    r = adapter.send(request, **kwargs)
  File "C:\Python27\lib\site-packages\requests\adapters.py", line 423, in send
    for i in request.body:
TypeError: 'Error' object is not iterable

Honestly there are probably many things wrong with the code here, I just need some direction on where to find the row or column ID. All help is appreciated, thanks!


回答1:


If you execute the Get Sheet operation, the response will be a Sheet object that contains (amongst other things), a collection of rows and a collection of columns that the Sheet contains (including an id attribute for each row and each column).

The Get Sheet operation requires that you specify sheetId. You can get the Id of a Sheet either manually via the Smartsheet UI (via Sheet properties) or via the API by using any operation that returns Sheet objects (for example: List Sheets, Get Folder, List All Contents, Search Everything, etc.).



来源:https://stackoverflow.com/questions/38093751/how-to-find-a-row-id-or-column-id-in-smartsheet

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!