Rocket.Chat's Community Open Call 🎤 Jan 19th, 2022 Join us!

IM.Files API call cannot find roomId or empty when by username

Description

I am trying to query the RocketChat API to see and possibly download files posted in channels and direct messages. I am following the official API documentation here for the IM endpoint for files.

It fails when I query by roomId but I get a success when I run it by username. Though the success only give me a empty list so I know it is wrong (as the user has uploaded multiple files).

I am using the rid (roomId) listed in in the collection rocketchat_uploads

See the end of the post for the logs.

Curl API Calls

Curl Call by roomId
curl -H "X-Auth-Token: MyGeneratedAuthTokenForAdminUser" \
     -H "X-User-Id: 62izDxKnF3Zt4JJh5 " \
     https://RocketChat.OrgDomain.com/api/v1/im.files?roomId=LHtgHWbLqEx3pcYmMg4kLKTgDih7FvZDvg
Curl call by username
curl -H "X-Auth-Token: MyGeneratedAuthTokenForAdminUser" \
     -H "X-User-Id: 62izDxKnF3Zt4JJh5 " \
     https://RocketChat.OrgDomain.com/api/v1/im.files?username=john.smith

Expectations
My query is correct but the system apparently is not finding the roomId. I would expect it to work as that is the room Id listed in the MongoDB and the roomId found using the API.

Let me know what I am doing incorrectly.

Server Setup Information

  • Version of Rocket.Chat Server: 4.2
  • Operating System: Ubuntu 20.04
  • Deployment Method: Manual Install
  • Number of Running Instances: 1
  • DB Replicaset Oplog:
  • NodeJS Version: 12.18.4
  • MongoDB Version: 4.4.10
  • Proxy: nginx
  • Firewalls involved: none

Any additional Information

Logs

Log Output roomId
{"level":35,"time":"2022-01-12T19:13:35.419Z","pid":27204,"hostname":"rocketchat","name":"API","method":"GET","url":"/api/v1/channels.files?roomId=LHtgHWbLqEx3pcYmMg4kLKTgDih7FvZDvg","userId":"62izDxKnF3Zt4JJh5","userAgent":"Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.19041.1320","host":"rocketchat.OrgDomain.com","remoteIP":"192.168.52.68","err":{"type":"errorClass","message":"The required \"roomId\" or \"roomName\" param provided does not match any channel [error-room-not-found]","stack":"Error: The required \"roomId\" or \"roomName\" param provided does not match any channel [error-room-not-found]<br>    at findChannelByIdOrName (app/api/server/v1/channels.js:32:9)<br>    at Object.get (app/api/server/v1/channels.js:281:22)<br>    at app/api/server/api.js:407:96<br>    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)<br>    at Object._internalRouteActionHandler [as action] (app/api/server/api.js:407:39)<br>    at Route.share.Route.Route._callEndpoint (packages/nimble_restivus/lib/route.coffee:150:32)<br>    at packages/nimble_restivus/lib/route.coffee:59:33<br>    at packages/simple_json-routes.js:98:9","isClientSafe":true,"error":"error-room-not-found","reason":"The required \"roomId\" or \"roomName\" param provided does not match any channel","errorType":"Meteor.Error"},"status":400,"responseTime":3,"msg":"The required \"roomId\" or \"roomName\" param provided does not match any channel [error-room-not-found]"} 

I am pulling the rid directly from API calls for the rooms and I double checked it in the

Log Output username
{"level":35,"time":"2022-01-12T19:28:47.532Z","pid":27204,"hostname":"rocketchat","name":"API","method":"GET","url":"/api/v1/im.files?username=john.smith","userId":"62izDxKnF3Zt4JJh5","userAgent":"Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.19041.1320","host":"rocketchat.OrgDomain.com","remoteIP":"192.168.52.68","status":200,"responseTime":13} 
{"level":35,"time":"2022-01-12T19:28:47.533Z","pid":27204,"hostname":"rocketchat","name":"API","method":"GET","url":"/api/v1/im.files?username=john.smith","userId":"62izDxKnF3Zt4JJh5","userAgent":"Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.19041.1320","host":"rocketchat.OrgDomain.com","remoteIP":"192.168.52.68","status":200,"responseTime":17} 

HI! I will try to replicate this, but looks like you are solid on your tests.

Maybe we can create an issue on our github?

THanks!

I have opened an issue as requested.

1 Like