Unable to upload file to Box using Node

I'm having a really tough time getting my files to upload to box using Node.js.

Every single time I attempt to, I get the following error:

Error: cannot POST /api/2.0/files/content (400)

Here is the relevant code. I've already double checked that this.options.auth contains the required tokens, etc. The parent_id folder is the root folder, so '0'. The filepath is a stream, which is totally fine.

request.post('https://upload.box.com/api/2.0/files/content')
.set('Authorization', this.options.auth)
.field('parent_id', folder)
.attach('filename', filepath)
.end(function (res) {
  if (res.error) {
    return callback('Error: '+res.error.message);
  }
  callback(null, res.body);
});

Any ideas?

Answers


HTTP status code 400 is used for a bad request. One thing to check is that the parameters you are supplying are all valid and that you haven't forgotten any required parameters. Looking at the Box API getting-started doc, it appears that what you are calling parent_id should be just parent. If it still doesn't work, check for other similar issues too, of course.


Need Your Help

Undefined reference to vtable in Qt Widgets [Codeblocks]

c++ qt undefined codeblocks vtable

I'm getting the error "reference undefined to "vtable for FlussoAudio" in this code, i can't find a reason for this error.