Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Its not possible to find the room id (rid) from the Api which is needed for most of the api calls #2879

Closed
bechlin opened this issue Apr 14, 2016 · 2 comments

Comments

@bechlin
Copy link

bechlin commented Apr 14, 2016

Your Rocket.Chat version: 0.25.0

With reference to this...

https://rocket.chat/docs/master/developer-guides-4-rest-api

It explains how to login and get a list of public rooms with these end points...

http://localhost:3000/api/login
http://localhost:3000/api/publicRooms

Then the api doc explains that in the subsequent calls you need to start using a rid (room id) in the end point urls..

http://localhost:3000/api/rooms/x4pRahjs5oYcTYu7i/join
http://localhost:3000/api/rooms/x4pRahjs5oYcTYu7i/leave
http://localhost:3000/api/rooms/x4pRahjs5oYcTYu7i/messages

where x4pRahjs5oYcTYu7i is the rid.

But how do you get this room id from an api call? It seems that there are no initial calls that enable you to get these room ids.

The /messages end point provides the rid in the json response but you need to use the rid in the first place with the api/rooms//messages before you can get the rid in the response.

Maybe I'm missing something obvious?

@richardwlu
Copy link

In that doc there is a Get list of public rooms via REST API call

curl -H "X-Auth-Token: 9HqLlyZOugoStsXCUfD_0YdwnNnunAJFV47U3QHXSq"
  -H "X-User-Id: aobEdbYhXfu5hkeqG"
  http://localhost:3000/api/publicRooms

{
  "status": "success",
  "rooms": [
    {
      "_id": "GENERAL",
      "usernames": [
        "admin",
        "sing"
      ],
     "ts": "2015-07-24T14:35:23.542Z",
     "t": "c",
      "other fields": "other fields ...."

The room id is _id

@bechlin
Copy link
Author

bechlin commented Apr 14, 2016

Ah, brilliant. That's working.

I thought I'd tried that but turns out I only tried it using the rid=GENERAL with the "join" end point. And you get an error with that...

REQUEST

GET http://ec2-54-201-180-143.us-west-2.compute.amazonaws.com:3000/api/rooms/GENERAL/join

Request Headers:
Connection: keep-alive
Accept-Encoding: gzip, deflate
X-User-Id: 6eJ6cZG6azfLj24QX
X-Auth-Token: Pr0LETAKk6BDzL95J5mPzFc8wvg8r8ZQv4r7EIi0BfT
Host: ec2-54-201-180-143.us-west-2.compute.amazonaws.com:3000
User-Agent: Apache-HttpClient/4.2.6 (java 1.5)

RESPONSE
Response headers:
HTTP/1.1 405 Method Not Allowed
Vary: Accept-Encoding
Access-Control-Allow-Origin: *
Cache-Control: no-store
Pragma: no-cache
content-type: application/json
allow: POST, OPTIONS
Date: Thu, 14 Apr 2016 16:39:53 GMT
Connection: keep-alive
Transfer-Encoding: chunked

{
"status": "error",
"message": "API endpoint does not exist"
}

Works with GET messages and POST messages. Maybe it doesn't work with the Join because you're already joined on this GENERAL room?

Anyway really appreciate the fast response. Great product :-)

@bechlin bechlin closed this as completed Apr 14, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants