Open wwc-trevor opened 2 years ago
I will work on this issue.
Hey @wwc-trevor , I am not able to reproduce the error. Both roomId and username params give the expected results. Also, I think that it retrieves files from direct messages only as mentioned in the docs
@sohamp19 I am trying to extract the files uploaded in direct messages between users. I can spend time and go step by step. but a overview is:
NOTE Room is a direct message room (type: d):
Go and make my curl call.
curl.exe -H "X-Auth-Token: MySecureUserToken" -H "X-User-Id: 62izDxKnF3Zt4JJh5" https://RocketChat.wallawallaclinic.com/api/v1/im.files?roomId=LHtgHWbLqEx3pcYmMzXnpAxYRoAZ4LjX6R
Get error message (see photo above).
{"success":false,"error":"The required \"roomId\" or \"username\" param provided does not match any direct message [error-room-not-found]","errorType":"error-room-not-found"}
If I am doing something incorrect I cannot tell. You let me know
@wwc-trevor I am still not able to reproduce it.
Here is what I tried.
Took the rid from rocketchat_uploads collection (Image below).
Verified that the type of room is 'd' (Image below).
Make a curl request to /api/v1/im.files endpoint
curl -H "X-Auth-Token: MyAuthToken" -H "X-User-Id: dKePxY9xWMDAtrqqS" http://localhost:3000/api/v1/im.files\?roomId\=dKePxY9xWMDAtrqqShedAszv5dMHfFjsbk
Result:
{
"files": [
{
"_id": "4p8pqkSnEHWeh8Xyw",
"name": "gcp_quest1.jpeg",
"size": 40592,
"type": "image/jpeg",
"rid": "dKePxY9xWMDAtrqqShedAszv5dMHfFjsbk",
"userId": "dKePxY9xWMDAtrqqS",
"store": "GridFS:Uploads",
"identify": {
"format": "jpeg",
"size": {
"width": 1280,
"height": 243
}
},
"complete": true,
"etag": "zCAM4DmmnvYZa4yiK",
"path": "/ufs/GridFS:Uploads/4p8pqkSnEHWeh8Xyw/gcp_quest1.jpeg",
"progress": 1,
"token": "980908db58",
"uploadedAt": "2022-01-19T20:15:32.582Z",
"uploading": false,
"url": "http://localhost:3000/ufs/GridFS:Uploads/4p8pqkSnEHWeh8Xyw/gcp_quest1.jpeg",
"_updatedAt": "2022-01-19T20:15:32.588Z",
"typeGroup": "image",
"user": {
"_id": "dKePxY9xWMDAtrqqS",
"username": "soham.parate",
"name": "Soham Parate"
}
},
{
"_id": "2rbhQqpaCeFKdN5oa",
"name": "gojo-chibi.jpg",
"size": 25153,
"type": "image/jpeg",
"rid": "dKePxY9xWMDAtrqqShedAszv5dMHfFjsbk",
"userId": "dKePxY9xWMDAtrqqS",
"store": "GridFS:Uploads",
"identify": {
"format": "jpeg",
"size": {
"width": 600,
"height": 600
}
},
"complete": true,
"etag": "KcyYCZtnmA85Pjksj",
"path": "/ufs/GridFS:Uploads/2rbhQqpaCeFKdN5oa/gojo-chibi.jpg",
"progress": 1,
"token": "4B0959fbCa",
"uploadedAt": "2022-01-19T19:45:48.259Z",
"uploading": false,
"url": "http://localhost:3000/ufs/GridFS:Uploads/2rbhQqpaCeFKdN5oa/gojo-chibi.jpg",
"_updatedAt": "2022-01-19T19:45:48.265Z",
"description": "gojo-chibi",
"typeGroup": "image",
"user": {
"_id": "dKePxY9xWMDAtrqqS",
"username": "soham.parate",
"name": "Soham Parate"
}
},
{
"_id": "E4koes2tvX9DjLapQ",
"name": "kitten.png",
"size": 132907,
"type": "image/png",
"rid": "dKePxY9xWMDAtrqqShedAszv5dMHfFjsbk",
"userId": "dKePxY9xWMDAtrqqS",
"store": "GridFS:Uploads",
"identify": {
"format": "png",
"size": {
"width": 384,
"height": 251
}
},
"complete": true,
"etag": "tHC8Y8t4w3kiki2XD",
"path": "/ufs/GridFS:Uploads/E4koes2tvX9DjLapQ/kitten.png",
"progress": 1,
"token": "7b595bbbFA",
"uploadedAt": "2022-01-19T20:12:40.964Z",
"uploading": false,
"url": "http://localhost:3000/ufs/GridFS:Uploads/E4koes2tvX9DjLapQ/kitten.png",
"_updatedAt": "2022-01-19T20:12:40.971Z",
"typeGroup": "image",
"user": {
"_id": "dKePxY9xWMDAtrqqS",
"username": "soham.parate",
"name": "Soham Parate"
}
},
{
"_id": "tm8it6dooFQbFv2du",
"name": "pfp1compressed.jpeg",
"size": 155602,
"type": "image/jpeg",
"rid": "dKePxY9xWMDAtrqqShedAszv5dMHfFjsbk",
"userId": "hedAszv5dMHfFjsbk",
"store": "GridFS:Uploads",
"identify": {
"format": "jpeg",
"size": {
"width": 1599,
"height": 1066
}
},
"complete": true,
"etag": "MNjYGywzjn3B8TM35",
"path": "/ufs/GridFS:Uploads/tm8it6dooFQbFv2du/pfp1compressed.jpeg",
"progress": 1,
"token": "2aF998491b",
"uploadedAt": "2022-01-19T20:18:55.260Z",
"uploading": false,
"url": "http://localhost:3000/ufs/GridFS:Uploads/tm8it6dooFQbFv2du/pfp1compressed.jpeg",
"_updatedAt": "2022-01-19T20:18:55.265Z",
"typeGroup": "image",
"user": {
"_id": "hedAszv5dMHfFjsbk",
"username": "soham-test",
"name": "soham-test"
}
},
{
"_id": "EniRF6Bv6XRDQrRFz",
"name": "thumb-gcp_quest1.jpeg",
"size": 6479,
"type": "image/jpeg",
"rid": "dKePxY9xWMDAtrqqShedAszv5dMHfFjsbk",
"userId": "dKePxY9xWMDAtrqqS",
"store": "GridFS:Uploads",
"identify": {
"format": "jpeg",
"size": {
"width": 480,
"height": 91
}
},
"complete": true,
"etag": "HNNQsiYxbyWQFyiwM",
"path": "/ufs/GridFS:Uploads/EniRF6Bv6XRDQrRFz/thumb-gcp_quest1.jpeg",
"progress": 1,
"token": "a90A495a89",
"uploadedAt": "2022-01-19T20:15:32.618Z",
"uploading": false,
"url": "http://localhost:3000/ufs/GridFS:Uploads/EniRF6Bv6XRDQrRFz/thumb-gcp_quest1.jpeg",
"user": {
"_id": "dKePxY9xWMDAtrqqS",
"username": "soham.parate",
"name": "Soham Parate"
}
},
{
"_id": "Jp9rmq7z3fcDa9v95",
"name": "thumb-gojo-chibi.jpg",
"size": 11981,
"type": "image/jpeg",
"rid": "dKePxY9xWMDAtrqqShedAszv5dMHfFjsbk",
"userId": "dKePxY9xWMDAtrqqS",
"store": "GridFS:Uploads",
"identify": {
"format": "jpeg",
"size": {
"width": 360,
"height": 360
}
},
"complete": true,
"etag": "6cBBBH25hjJjf7kBM",
"path": "/ufs/GridFS:Uploads/Jp9rmq7z3fcDa9v95/thumb-gojo-chibi.jpg",
"progress": 1,
"token": "6a0acb4938",
"uploadedAt": "2022-01-19T19:45:48.302Z",
"uploading": false,
"url": "http://localhost:3000/ufs/GridFS:Uploads/Jp9rmq7z3fcDa9v95/thumb-gojo-chibi.jpg",
"user": {
"_id": "dKePxY9xWMDAtrqqS",
"username": "soham.parate",
"name": "Soham Parate"
}
},
{
"_id": "FyZoZePkCndrGN4H7",
"name": "thumb-pfp1compressed.jpeg",
"size": 31738,
"type": "image/jpeg",
"rid": "dKePxY9xWMDAtrqqShedAszv5dMHfFjsbk",
"userId": "hedAszv5dMHfFjsbk",
"store": "GridFS:Uploads",
"identify": {
"format": "jpeg",
"size": {
"width": 480,
"height": 320
}
},
"complete": true,
"etag": "XvQv6sErdqRDt2MoX",
"path": "/ufs/GridFS:Uploads/FyZoZePkCndrGN4H7/thumb-pfp1compressed.jpeg",
"progress": 1,
"token": "1a086A2BD9",
"uploadedAt": "2022-01-19T20:18:55.329Z",
"uploading": false,
"url": "http://localhost:3000/ufs/GridFS:Uploads/FyZoZePkCndrGN4H7/thumb-pfp1compressed.jpeg",
"user": {
"_id": "hedAszv5dMHfFjsbk",
"username": "soham-test",
"name": "soham-test"
}
}
],
"count": 7,
"offset": 0,
"total": 7,
"success": true
}
And I am using Rocket.Chat 4.4.0-develop. I just noticed :) Maybe this is fixed in newer versions
And I am using Rocket.Chat 4.4.0-develop. I just noticed :) Maybe this is fixed in newer versions
I hope so. Almost all the other API calls I have made have been successful but this one. DO you know when 4.4 is going to be released? I saw 4.3.2 is the latest.
@wwc-trevor no idea sir
Do you think it could be something with my reverse proxy?
Hey!! I want to work on this issue. I'm new here so I'm really excited to start contributing.
Hi, @wwc-trevor , can you assign me this issue
Hey @wwc-trevor I think @sohamparate is right This endpoint seems to be working fine according to the documentation
It is displaying the file's sent in direct message's
here i sent a file named apply_proxy
@ggazzo , On reproducing this error i have found that the api is working as shown in the documentation
{
"files": [
{
"_id": "657a9bccd111bca61b353acd",
"name": "codecell proposal (1).pdf",
"size": 33986,
"type": "application/pdf",
"rid": "65796859d315d66597ec1c7d",
"userId": "EwgzmJMJsWecQcSxz",
"store": "GridFS:Uploads",
"_updatedAt": "2023-12-14T06:08:12.677Z",
"complete": true,
"etag": "Z4TtgxnfpGAfRzRts",
"path": "/ufs/GridFS:Uploads/657a9bccd111bca61b353acd/codecell%20proposal%20(1).pdf",
"progress": 1,
"token": "2AD889EBF8",
"uploadedAt": "2023-12-14T06:08:12.672Z",
"uploading": false,
"url": "https://3000-rocketchat-rocketchat-1z832tjp3fk.ws-us106.gitpod.io/ufs/GridFS:Uploads/657a9bccd111bca61b353acd/codecell%20proposal%20(1).pdf",
"description": "ekrjafdnkjwds\\",
"typeGroup": "application",
"user": {
"_id": "EwgzmJMJsWecQcSxz",
"name": "smit",
"username": "smitty"
}
}
],
"count": 1,
"offset": 0,
"total": 1,
"success": true
}
@wwc-trevor is this issue is still open?
@Asrani-Aman I think the issue is solved since the endpoint is giving the expected response
Please close this issue if this issue is solved
If this issue is open .please assign it to me . @wwc-trevor
Description:
When using curl to query the files.im api endpoint by roomId it states it cannot find the roomId. The roomID entered is the one listed in the MongoDB collection rocketchat_uploads.
When I query by username it states it is successful but list no files.
Steps to reproduce:
curl -H "X-Auth-Token: MyGeneratedAuthTokenForAdminUser" -H "X-User-Id: 62izDxKnF3Zt4JJh5" https://RocketChat.OrgDomain.com/api/v1/im.files?roomId=LHtgHWbLqEx3pcYmMg4kLKTgDih7FvZDvg
[^1]curl.exe -H "X-Auth-Token: MyGeneratedAuthTokenForAdminUser" -H "X-User-Id: 62izDxKnF3Zt4JJh5" https://rocketchat.wallawallaclinic.com/api/v1/im.files?username=trevor.moses
[^1]Expected behavior:
Return with data as shown in official rocketchat documentation using the room id (rid) listed in in rocketchat_uploads collection.
Actual behavior:
When querying by RoomId I get:
{"success":false,"error":"The required \"roomId\" or \"username\" param provided does not match any direct message [error-room-not-found]","errorType":"error-room-not-found"}
I am getting the roomId (rid) from the MongoDB collection rocketchat_uploads. The RocketChat Server logs shown that it cannot find the room.
When querying by username I get results but they are empty.
curl -H "X-Auth-Token: MyGeneratedAuthTokenForAdminUser" -H "X-User-Id: 62izDxKnF3Zt4JJh5" https://RocketChat.OrgDomain.com/api/v1/im.files?roomId=LHtgHWbLqEx3pcYmMg4kLKTgDih7FvZDvg
{"files":[],"count":0,"offset":0,"total":0,"success":true}
Server Setup Information:
Client Setup Information
Additional context
Relevant logs:
Query by RoomID Rocketchat Server Log
{"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]at findChannelByIdOrName (app/api/server/v1/channels.js:32:9)
at Object.get (app/api/server/v1/channels.js:281:22)
at app/api/server/api.js:407:96
at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1234:12)
at Object._internalRouteActionHandler [as action] (app/api/server/api.js:407:39)
at Route.share.Route.Route._callEndpoint (packages/nimble_restivus/lib/route.coffee:150:32)
at packages/nimble_restivus/lib/route.coffee:59:33
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]"}
Query by Username Rocketchat Server Log
{"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}Screenshot
[^1]: Actual auth token not share for security purposes.