Webhook "Error Code: 1151 - Scope 'sheet', object id <id> was not found"

edited 12/09/19 in API & Developers
09/10/19 Edited 12/09/19

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.

However, now when a external customer (admin user 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] POST https://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] POST https://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 <id> was not found.

Ref ID: xb9zhox8mpu3

https://smartsheet-platform.github.io/api-docs/#create-webhook is 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 <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

Sign In or Register to comment.