I am currently facing an issue while trying to create and upload a new bucket for storing models. I keep getting a 400 Bad Request error, even though I managed to make it work in a previous project using a different method. Strangely enough, I now encounter the same error in that project as well.
The function in my routes folder to post a bucket is shown below:
router.post('/buckets', async (req, res, next) => {
let payload = new PostBucketsPayload();
payload.bucketKey = config.credentials.client_id.toLowerCase() + '-' + req.body.bucketKey;
payload.policyKey = 'Persistent';
console.log('PAYLOAD: ', payload, '\nCLIENT: ', req.oauth_client, '\nTOKEN: ', req.oauth_token);
try {
await new BucketsApi().createBucket(payload, {}, req.oauth_client, req.oauth_token);
res.status(200).end();
} catch (err) {
next(err);
}
});
In my tree.js file, the code for creating a new bucket looks like this:
function createNewBucket() {
var bucketKey = $('#newBucketKey').val();
jQuery.post({
url: '/api/forge/oss/buckets',
contentType: 'application/json',
data: JSON.stringify({ 'bucketKey': bucketKey }),
success: function (res) {
$('#userHubs').jstree(true).refresh();
$('#createBucketModal').modal('toggle');
},
error: function (err) {
if (err.status == 409)
alert('Bucket already exists - 409: Duplicated')
console.log(err);
}
});
}
Although everything seemed fine before, I have started experiencing this issue after changing the callback URL and client secret/ID. If there are any critical details missing or if you have suggestions on how to resolve this problem, please feel free to share them with me.
Thank you for your help!