Chris Dix avatar image
Chris Dix asked Phong Vu answered

Unable to download attachments from a post

I have a bot that has been graduated and is able to make calls to the endpoint to get posts:

I am also able to receive information about the same posts via webhook. In both cases, the bot is using the persistent token retrieved by the bot using the code we receive when added to the environment.

However, I am not able to retrieve the contents of the post attachments using that same token. The content URI comes in this format:

I have tried using a browser, Postman, and code (C#). I have tried providing the token in the Authorization header ("Bearer TTT") as well as on the query string as shown in another example, but all responses are always 404 with this JSON:

{ "errors" :
"errorCode" : "CMN-102" ,
"message" : "Resource for parameter [fileId] is not found." ,
"parameterName" : "fileId" } ] }

Can the bot persistent token be used to retrieve attachment data? If not, how can I obtain the token that will work to download attachment data without user interaction?


1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Phong Vu avatar image
Phong Vu answered

First of all, your bot access token has the right to read posts and attachments under a team/chat/conversation the bot is a member of.

In your case, I don't see the code nor the environment so it's hard for me to tell what could be wrong. This is how I could successfully download a binary file attachment in my bot using Node JS.

const url = require('url')
  var attachmentUri = ""
  var accessToken = "Valid-AccessToken"
  download(attachmentUri, accessToken, (err, content) => {
var https = require('https');
const download = function(attachmentUri, token, cb) {
  var file = fs.createWriteStream("testing.png");
  var u = url.parse(attachmentUri);
  var options = {
    path: u.pathname,
    method: "GET",
    headers: {
        Authorization: `Bearer ${token}`

  const req = https.request(options, res => {
    var chunks = [];
    res.on('data', (chunk) => {
      chunks += chunk;
    }).on('end', () => {
      file.write(chunks, 'binary');
      file.on('finish', () => {
        console.log('File Saved !');
  req.on('error', error => {

If you believe that your code is correct and you still receive the error, I recommend to submit a dev support ticket so you can provide more details for the investigation.

1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys