Skip to main content
Question

Where to find file_id for download with box-node-sdk

  • May 22, 2025
  • 1 reply
  • 32 views

Forum|alt.badge.img

I know this is a really dumb question but I cannot find a clear answer: what is a file_id? If I get a shared link for one of my files I see this:

 

https://---.box.com/s/w6623rvaz36xucb0jlmukio5zyk6se97

 

Is w6623rvaz36xucb0jlmukio5zyk6se97 the file_id? Or is it found somewhere else? The file properties does not show a file_id field. If I use the string above to download in a file in box-node-sdk I get a "not_found" error.

 

Postman:

 

localhost:5000/boxapi/file/w6623rvaz36xucb0jlmukio5zyk6se97/

 

Node Server boxapi.js:

 

router.get('/file/:id', (req, res) => {
console.log(`Box API get file with ID ${req.params.id}`);
boxClient.files.getReadStream(req.params.id, null, function(error, stream) {
if (error) {
console.log(`Box API error in downloading file with ID ${req.params.id}`);
return res.status(400).json({ error: error });
}
// write the file to disk
var output = fs.createWriteStream('/public/images/test.png');
stream.pipe(output);
console.log('Box API wrote file test.png to disk');
});
});
 
response (partial):
 
"response": {
"statusCode": 404,
"body": {
"type": "error",
"status": 404,
"code": "not_found",
"help_url": "http://developers.box.com/docs/#errors",
"message": "Not Found",
"request_id": "w7aivvg0fg1n54or"
},

1 reply

Forum|alt.badge.img

Hi  !

 

Not a dumb question at all 🙂 You're really very close. A file ID is a numeric identifier for a file, unique across all of Box. The shared "hash" in a shared link is technically also a type of ID in the sense that it's a unique identifier for an item, but it's not the actual file ID.

 

To get the file ID, try this method:

https://github.com/box/box-node-sdk/blob/master/docs/shared-items.md

 

It'll return a numeric file ID, assuming that the link is either open or your user has access to the item via a collaboration.

 

If you want to see an example of what the base API call looks like (and the response), check out this section:

https://developer.box.com/reference#get-a-shared-item

 

A sample response is on the right hand side. Hope that helps!

 

Thanks,

Jason