Webhook "Error Code: 1151 - Scope 'sheet', object id was not found"
Working on implementing a basic webhook based smartsheet connector to fetch usage data for users under one organization. During the Oauth2.0 flow, requested for following scopes "READ_USERS, ADMIN_USERS, ADMIN_WEBHOOKS".
I am making the following javascript-sdk api calls : -
- smartsheetClient.users.listAllUsers
- smartsheetClient.sheets.listOrganizationSheets
- smartsheetClient.webhooks.createWebhook
- smartsheetClient.webhooks.updateWebhook
As I am the admin of my company's smartsheet account, generated the access token using my admin account (authorization). Here, first I created the integration app in Developer Tools via my account. The connector flow is working fine, i am able to fetch a list of sheets under my org account (https://smartsheet-platform.github.io/api-docs/#list-org-sheets)and then able to create webhook per sheet (https://smartsheet-platform.github.io/api-docs/#create-webhook), and then whenever a smartsheet event is occuring on those sheet, I am able to receive a webhook payload event.
然而,现在当一个外部客户(管理员用户of some org) authorizes us access for their smartsheet account (with same scopes "READ_USERS, ADMIN_USERS, ADMIN_WEBHOOKS"), fetching of sheets (smartsheetClient.sheets.listOrganizationSheets) is working fine, however creating webhook per sheet is not working). Getting the following error : -
[Smartsheet] 2019-09-10T16:49:26.281Z[ INFO] POSThttps://api.smartsheet.com/2.0/webhooks/
[Smartsheet] 2019-09-10T16:49:26.564Z[ ERROR] Request failed after 0 retries
[Smartsheet] 2019-09-10T16:49:26.565Z[ ERROR] POSThttps://api.smartsheet.com/2.0/webhooks/
[Smartsheet] 2019-09-10T16:49:26.565Z[ ERROR] Response: Failure (HTTP 404)
Error Code: 1151 - Scope 'sheet', object id
Ref ID: xb9zhox8mpu3
https://smartsheet-platform.github.io/api-docs/#create-webhookis failing.
Please let me know in case I am doing something wrong is access scopes requested or any other kind of error.
Comments
-
When making the request to create a webhook there is a scopeObjectId attribute that needs to be set to the Sheet ID of the sheet you are setting the webhook on.
The error is noting "Scope 'sheet', object id
was not found. " so it looks like that sheet cannot be found by the request. I suggest looking at how the Sheet ID is getting set in your code and how it could be getting set incorrectly to a Sheet ID that is invalid for this user. It could be that the particular user who is doing this doesn't have access to the sheet, so API requests involving that Sheet ID fail with the Not Found error since it isn't found under their account. If they are a System Admin they can list all sheets of the org, but doesn't mean they have been shared access to all of the sheets, so they may not be able to perform requests on the sheets if they haven't been shared to it in Smartsheet. -
Thanks a lot for the help. This helps in understanding the root cause of the problem.
Can I ask you another question then,
Is there a way to create webhooks for all the sheets under one organization account (like we can fetch list of all sheets of the org)? I am basically interested in retrieving all the usage data with respect to all sheets in an org. -
There isn't a specific request to make webhooks for all sheets in one organization account. One would have to have access to all sheets to be able to create webhooks for them.
If the user is a System Admin they could go through the process of assuming the role of each of their users and then setting webhooks for all of their sheets. Info on the Asume-User header is in the docs here:
http://smartsheet-platform.github.io/api-docs/#http-headers
If you are looking to get usage data on sheets in the account there is the Event reporting API. It is only for Enterprise and above plans. But, it could be what you need. More info is in the docs here:
http://smartsheet-platform.github.io/api-docs/#event-reporting
Categories
=IFERROR(INDEX(DISTINCT(LOWER(<\/strong>COLLECT(.....................))<\/strong>), 1), \"//www.santa-greenland.com/community/discussion/57416/\")<\/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":107674,"type":"question","name":"API PUT and Body help for Cell link from a cell in sheet \"a\" to sheet \"b\"","excerpt":"I am having trouble linking a cell from sheet a to b. I am new to using API and possibly just getting the call wrong? or the body. Any help would be appreciated. PUT: https:\/\/api.smartsheet.com\/2.0\/sheets\/4098048888098692\/rows\/1370574824361860\/cells\/259016080 Body: { \"cells\": [ { \"linkinFromCell\": {…","snippet":"I am having trouble linking a cell from sheet a to b. I am new to using API and possibly just getting the call wrong? or the body. Any help would be appreciated. PUT:…","categoryID":320,"dateInserted":"2023-07-17T16:23:24+00:00","dateUpdated":"2023-07-18T10:24:44+00:00","dateLastComment":"2023-07-18T16:45:05+00:00","insertUserID":135530,"insertUser":{"userID":135530,"name":"Carlo Rodriguez","url":"https:\/\/community.smartsheet.com\/profile\/Carlo%20Rodriguez","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-07-21T15:50:31+00:00","banned":0,"punished":0,"private":false,"label":"✭✭"},"updateUserID":91566,"lastUserID":135530,"lastUser":{"userID":135530,"name":"Carlo Rodriguez","url":"https:\/\/community.smartsheet.com\/profile\/Carlo%20Rodriguez","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-07-21T15:50:31+00:00","banned":0,"punished":0,"private":false,"label":"✭✭"},"pinned":false,"pinLocation":null,"closed":false,"sink":false,"countComments":2,"countViews":58,"score":null,"hot":3379310909,"url":"https:\/\/community.smartsheet.com\/discussion\/107674\/api-put-and-body-help-for-cell-link-from-a-cell-in-sheet-a-to-sheet-b","canonicalUrl":"https:\/\/community.smartsheet.com\/discussion\/107674\/api-put-and-body-help-for-cell-link-from-a-cell-in-sheet-a-to-sheet-b","format":"Rich","tagIDs":[472,563],"lastPost":{"discussionID":107674,"commentID":385785,"name":"Re: API PUT and Body help for Cell link from a cell in sheet \"a\" to sheet \"b\"","url":"https:\/\/community.smartsheet.com\/discussion\/comment\/385785#Comment_385785","dateInserted":"2023-07-18T16:45:05+00:00","insertUserID":135530,"insertUser":{"userID":135530,"name":"Carlo Rodriguez","url":"https:\/\/community.smartsheet.com\/profile\/Carlo%20Rodriguez","photoUrl":"https:\/\/us.v-cdn.net\/6031209\/uploads\/defaultavatar\/nWRMFRX6I99I6.jpg","dateLastActive":"2023-07-21T15:50:31+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-18T16:45:08+00:00","dateAnswered":"2023-07-18T11:38:00+00:00","acceptedAnswers":[{"commentID":385713,"body":"
<\/p>