Trying to create webhook with Box CLI - getting 404 error
Hi, I am new to box app development and any help would be appreciated.
Tried to create a webhook from the developer console but did not work. Read somewhere that permissions is required for that from Box.
So I am trying to create one from the CLI(installed Box CLI and set up the env as suggested) . Checked Manage Webhooks in the app configuration, in Enterprise Settings authorized the app etc. but am getting 404 Not found(both for file and folder) error when I run the CLI command to create the webhook. Used the folder id from the URL(https://app.box.com/folder/***number removed for privacy***0)
=>box webhooks:create folder ***number removed for privacy***0 --triggers="ITEM.CREATE,ITEM_UPLOAD" --address="https://VaidURLthatworks"
What could I be missing?
-
Hi ,
This is mainly an assumption, but I'd say that this is most likely due to a scoping issue. In short, when you configured the CLI (box configure:environments:add) with the JSON file you downloaded from the app you created, that is scoping the CLI for your app (the service account) and not your user. Basically the files / folders that the CLI is referring to are those owned within the service account, and I'm guessing that you are trying to refer to files / folders that are owned by one of your users? The service account by default will not have access to those assets unless you add it as a collaborator.
If all the above sounds correct to your situation, try running the webhook create command with the as-user flag of the user that owns the file / folder. Basically it'll look like this:
box webhooks:create folder $FOLDER_ID --triggers="ITEM.CREATE,ITEM_UPLOAD" --address="https://VaidURLthatworks" --as-user=$ID_OF_USER_WHO_OWNS_CONTENT
Hope that helps,
Jon
-
ok perfect, then yes it's most likely a scoping issue. The service account behind the scenes is like a programmatic user account (app user) and thus it has its own file storage. The command I provided should work, and here's how you get your user ID for the --as-user flag:
- Go to box.com and log in. Click on your picture / icon at the top right of the page and select "Account Settings" from the drop down menu.
- Scroll down to the account details section. In that section there should be an item for "Account ID" - that's your user ID. Use that # for the --as-user call and it should hopefully work.
-
Hi Jon thanks for being patient (:
What you suggested did not work as expected but it definitely looks like a scoping issue. Let me try to articulate my confusion here. Still trying to wrap my head around what may be going on here.
1) Folder created on the box.com site using my service account
2) Created a web app with jwt authentication as suggested. Created the configuration file with public private key.
3) Configured the CLI environment with the above json config file
4) Ran the create webhook command pointing to a folder created in #1. Like you said earlier since it is a differnt account in Box's view it did nit see the folder - error 404 not found
5) Tried creating a folder using the CLI, creation successful, but don't know how to see that folder(creation details as follows
Type: user
ID: '***number removed for privacy***'
Name:
Login: ***email address removed for privacy***6) Tried creating the webhook again using the --as-user= parameter as you sugested with the account ID - 403 Forbidden error now instead of 404 that I used to get
7) Changed the user ID to the ID that I got from the folder creation detail using CLI(the app id) I get this error: Unexpected API Response [403 Forbidden | fabcdf3wx57y] access_denied_insufficient_permissions - Access denied - insufficient permission
😎 Tried creating a webhook on a folder created using the CLI then also the same insufficient permission error
Confused User (:
Please sign in to leave a comment.
Comments
6 comments