Enable manage webhook
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.
-
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 credentialsvar sdk = new BoxSDK({clientID: CLIENTID,clientSecret: CLIENTSECRET});var requesttoken='x3nzT8cftNZOvAcH68SwRoYakkx56HMo9b1bcwqQxoDEbceChYtit436bsAyw7XK';TokenManager.findOne({ type:'refreshtoken' }, function (err, data) {// console.log('data====',data);if(data == null){console.log('in ifffffff====');TokenManager.create({ refreshtoken:requesttoken,type:'refreshtoken' }, function (err, small) {if (err) return handleError(err);// saved!});}else{requesttoken=data.refreshtoken;//requesttoken='XioYQyBX6twb08Zefyz91KaxAKBk1gu0b3eNaWTvQxkwgYH0n8bgt7peLAs7Tcis';}//console.log('requesttoken==',requesttoken);var options1 = {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(options1, callback44);})function callback44(error, response, body) {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}, (err, doc) => {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,[client.webhooks.triggerTypes.FILE.UPLOADED,client.webhooks.triggerTypes.FILE.DOWNLOADED]).then(webhook => {console.log('webhook====',webhook);});}else{//console.log('hreeeeeeeetop==',error,response);}}}
サインインしてコメントを残してください。
コメント
4件のコメント