Level up your Box knowledge with brand new learning paths on Box University. Visit training.box.com to get started

Enable manage webhook

New post

Comments

4 comments

  • jcleblanc

    Hi ,

     

    Can you post the code snippet that is causing that error please? From the error it sounds like something might need to be adjusted in the call to create the webhook.

     

    Thanks,

    Jon

    0
    Comment actions Permalink
  • DK

    I have enabled the manage webhooks from developer console but still i got 403 error. please have at my code

    exports.createwebhooks = function(req,res){
     
                    // Initialize the SDK with your app credentials
                    var sdk = new BoxSDK({
                        clientID: CLIENTID,
                        clientSecret: CLIENTSECRET
                        });
                        var requesttoken='x3nzT8cftNZOvAcH68SwRoYakkx56HMo9b1bcwqQxoDEbceChYtit436bsAyw7XK';
                        TokenManager.findOne({ type:'refreshtoken' }, function (errdata) {
                        // console.log('data====',data);
                            if(data == null){
                                console.log('in ifffffff====');
                                TokenManager.create({ refreshtoken:requesttoken,type:'refreshtoken' }, function (errsmall) {
                                    if (errreturn handleError(err);
                                    // saved!
                                });
                            }else{
                             requesttoken=data.refreshtoken;
                            //requesttoken='XioYQyBX6twb08Zefyz91KaxAKBk1gu0b3eNaWTvQxkwgYH0n8bgt7peLAs7Tcis';
                            }
                            //console.log('requesttoken==',requesttoken);
                            var options1 = {
                                url: 'https://api.box.com/oauth2/token',
                                method: 'POST',
                                headers: {
                                    'Content-Type': 'application/x-www-form-urlencoded'
                                },
                                form: {
                                    'client_id': CLIENTID,
                                    'client_secret': 'm7cMQZiRfIDNoFOsiYKHNadouDTon13h',
                                    'refresh_token': requesttoken,
                                    'grant_type': 'refresh_token',
                                }
                            };
                            request(options1callback44);
                        }) 
                        function callback44(errorresponsebody) {
                            console.log('response==',response); 
                            if (!error && response.statusCode == 200) {                    
                                var bodydata = JSON.parse(body); 
                                
                                console.log('bodydata==',bodydata);               
                                TokenManager.findOneAndUpdate({type:'refreshtoken'}, {$set:{refreshtoken:bodydata.refresh_token}}, {new: true}, (errdoc=> {
                                    if (err) {
                                        console.log("Something wrong when updating data!");
                                    }                    
                                    console.log('bodydata.access_token==',bodydata.access_token);
                                });                   
                                var client = sdk.getBasicClient(bodydata.access_token);
                                
                                    client.webhooks.create(
                                    '111280604678',
                                    client.itemTypes.FOLDER,
                                    'https://vpma.associationstudios.com/api/webhookdata',
                                    [
                                        client.webhooks.triggerTypes.FILE.UPLOADED,
                                        client.webhooks.triggerTypes.FILE.DOWNLOADED
                                    ])
                                    .then(webhook => {
                                        console.log('webhook====',webhook);
                                    });            
                            }
                            else
                            {
                                //console.log('hreeeeeeeetop==',error,response);
                            }
                        }

               
        
    }
    0
    Comment actions Permalink
  • DK

    is there any solution about webhook??

    0
    Comment actions Permalink
  • Vidya Sagar S

    How to enable the Webhooks for my newly created app?

    0
    Comment actions Permalink

Please sign in to leave a comment.