Nextcloud version: 30.0.4
Talk Server version: 20.1.5
Custom Signaling server configured: no
Custom TURN server configured: no
Custom STUN server configured: no
I cannot access messages from a chat. There are several, partly contradictory sources, none of which help me.
# Get details of Room of conversation
API_URL = f"{BASE_URL}/ocs/v2.php/apps/spreed/api/v4/room/jciamrcg"
HEADERS = {
"OCS-APIRequest": "true",
"Accept": "application/json",
"Content-Type": "application/json"
}
Authentication
For authentication, USERNAME and PASSWORD are used directly. The user can log in normally with the same credentials in the web client, so I rule out permission issues.
Token
Since reading a chat ({Token}
= jciamrcg) works with the Python code above works, I assume the token is correct:
According to this documentation, the endpoint to read all messages of the chat should be:
Base URL: /ocs/v2.php/apps/spreed/api/v1/
Endpoint: chat/{token}
Problem: I assume the documentation is not up-to-date, as I get a 500 - Internal Server Error when using v1
.
Solution: Therefore, I replace the base URL with:
Base URL: /ocs/v2.php/apps/spreed/api/v4/
(v4 is only mentioned on the homepage of the documentation.)
This results in:
GET /ocs/v2.php/apps/spreed/api/v4/chat/jciamrcg
Problem: Now I get a 404 error:
Invalid query, please check the syntax.
API specifications can be found here: Freedesktop API.
According to the guide in the Freedesktop link, section “MESSAGES - list”, the syntax should be:
/v1/message/"folder"
I assumed that the “folder” here should be the token of the conversation.
So I also tested:
/ocs/v2.php/apps/spreed/api/v1/message/jciamrcg
and got a 404 error again. The same happens with:
/ocs/v2.php/apps/spreed/api/v4/message/jciamrcg
.
Conclusion: I assume the endpoint is incorrect.
In my desperation, I have tested the following endpoints unsuccessfully:
/ocs/v2.php/apps/spreed/api/v4/chat/jciamrcg
/ocs/v2.php/apps/spreed/api/v4/chat/jciamrcg/messages
/ocs/v2.php/apps/spreed/api/v4/room/jciamrcg/
(this already reads the chat room)/ocs/v2.php/apps/spreed/api/v4/room/jciamrcg/messages