简单的行更新通过API/Powershell
刚刚开始使用API。只是想展示更新单元格的概念证明。我能够验证并获得表,行和列的详细信息。我得到了错误:
调用- restmethod: {"errorCode": 1008, "message": "无法解析请求。无法识别的令牌'value':正在等待('true', 'false'或'null')\n at[来源:REST输入;line: 1, column: 7]","refId": "1s91b4mmwsgg2"}
我在这里看到了一个类似的错误,但无法让它工作。对于新手问题,很抱歉.....
美元uri = "https://api.smartsheet.com/2.0/sheets/8497703870064516/rows”
$body = @{
'columnId ' = '229799331424132'
'value' = 'true'
}
调用- restmethod -Method put -Uri $uri -Headers $headers -body $body
最佳答案
-
谢谢。新鲜的眼睛和咖啡帮了大忙。让它工作。对于那些可能遇到这种情况的人:
美元uri = "https://api.smartsheet.com/2.0/sheets/aaaaaaaaaaaaaa/rows”
$身体= ' [{" id ": " rowid”,“细胞”:[{“columnId”:yyyyyy,“价值”:“zzzzzz“}]}]
答案
-
吉纳维芙P。 员工管理
我不熟悉Powershell语法,但根据收到的错误,听起来格式可能不正确。这是Powershell文档。
我建议在Powershell社区看看其他熟悉Powershell的用户能否提供帮助。
这里有一些其他的社区主题,可能也会有所帮助:
- 堆栈溢出:Powershell中意外的令牌错误
- 堆栈溢出:Powershell Invoke-RestMethod Smartsheet API添加附件到工作表
- 使用api.smartsheet.com的“Invoke-WebRequest”命令的正确语法是什么?
- SmartSheet Powershell模块提案
- (见:SmartSheet_Powershell_Module在GitHub)
欢呼,
吉纳维芙
-
谢谢。新鲜的眼睛和咖啡帮了大忙。让它工作。对于那些可能遇到这种情况的人:
美元uri = "https://api.smartsheet.com/2.0/sheets/aaaaaaaaaaaaaa/rows”
$身体= ' [{" id ": " rowid”,“细胞”:[{“columnId”:yyyyyy,“价值”:“zzzzzz“}]}]
-
吉纳维芙P。 员工管理
谢谢你的解决方案!我真的很感激
类别
See below link:<\/p>
https:\/\/smartsheet.redoc.ly\/tag\/groups#operation\/add-group<\/a><\/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":227,"urlcode":"api-and-developers","name":"API and Developers"},{"tagID":442,"urlcode":"groups-and-group-management","name":"Groups and Group Management"}]},{"discussionID":106741,"type":"question","name":"Using the API to get attachment URLs","excerpt":"I have PDF row attachments in a sheet. I need to get a direct URL to the attachment but I can't see a way to do this in the API. Using the GUI to \"send\" the file provides a link - so I'm trying to get something similar through the API. I'm aware that the the URL using the GUI method expires after 30 days. I would prefer…","categoryID":320,"dateInserted":"2023-06-21T22:40:34+00:00","dateUpdated":null,"dateLastComment":"2023-06-22T20:21:40+00:00","insertUserID":150432,"insertUser":{"userID":150432,"name":"jzadra","url":"https:\/\/community.smartsheet.com\/profile\/jzadra","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-06-22T22:12:59+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"updateUserID":null,"lastUserID":150432,"lastUser":{"userID":150432,"name":"jzadra","url":"https:\/\/community.smartsheet.com\/profile\/jzadra","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-06-22T22:12:59+00:00","banned":0,"punished":0,"private":false,"label":"✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":2,"countViews":24,"score":null,"hot":3374853734,"url":"https:\/\/community.smartsheet.com\/discussion\/106741\/using-the-api-to-get-attachment-urls","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/106741\/using-the-api-to-get-attachment-urls","format":"Rich","tagIDs":[227,268],"lastPost":{"discussionID":106741,"commentID":381846,"name":"Re: Using the API to get attachment URLs","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/381846#Comment_381846","dateInserted":"2023-06-22T20:21:40+00:00","insertUserID":150432,"insertUser":{"userID":150432,"name":"jzadra","url":"https:\/\/community.smartsheet.com\/profile\/jzadra","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-06-22T22:12:59+00:00","banned":0,"punished":0,"private":false,"label":"✭"}},"breadcrumbs":[{"name":"Home","url":"https:\/\/community.smartsheet.com\/"},{"name":"API & Developers","url":"https:\/\/community.smartsheet.com\/categories\/api-developers"}],"groupID":null,"statusID":3,"attributes":{"question":{"status":"accepted","dateAccepted":"2023-06-22T20:20:13+00:00","dateAnswered":"2023-06-22T00:36:56+00:00","acceptedAnswers":[{"commentID":381653,"body":"
https:\/\/api.smartsheet.com\/2.0\/sheets\/$Sheet_ID?include=attachments<\/a><\/p>
substituting $Sheet_ID for the sheet ID and get the attachment id for each row<\/p>
https:\/\/api.smartsheet.com\/2.0\/sheets\/$Sheet_ID\/attachments\/$This_Attachment_ID<\/a><\/p>