Skip to main content
Question

Enable manage webhook

  • May 22, 2025
  • 4 replies
  • 31 views

Forum|alt.badge.img

Hi,

I am trying to creating webhook in the box using node js. but i am geting below error.

" Unexpected API Response [400 Bad Request | 92k219gf4n2o84dh.0d7af43b9b17df6e137fa9a42eb6dc1e7] bad_request - Bad Request".

 

might be webhook is not enabled for our app. can you please suggest the solution. 

4 replies

Forum|alt.badge.img

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


Forum|alt.badge.img

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);
                        }
                    }

           
    
}

Forum|alt.badge.img

is there any solution about webhook??


Forum|alt.badge.img

How to enable the Webhooks for my newly created app?