Please bear with me if my wording is a little off. What I'm basically trying to do is write a script that runs on the server the ejabberd service is running on. This script is supposed to create a chat room and automatically subscribe users to it.
I am aware that this is possible through the REST API but I don't want to trigger this through a connection from the outside but from within the same physical server.
Or would the goto method then be to run the API calls through localhost?
UPDATE: As suspected I can simply call the REST API through localhost. But I'm still stuck. It's probably some typo in my config or the calls so I'll share what I tried here:
hey thanks for your response. I got this far myself but I'm not getting the expected result.
So i configured the necessary part in my yml file like so:
listen:
-
port: 5285
module: ejabberd_http
request_handlers:
"/rest": mod_rest
and added localhost to the hosts. I then tried to access a REST function like this:
curl -X POST -i -H "Content-type: application/json" http://localhost:5285/rest/create_room -d
'
{
"name":"testroom",
"service":"mychatservice.host.com",
"host":"host.com"
}
'
And I got this response:
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 21
Try POSTing a stanza.
I thought the 200 code meant I did right but when I checked with "ejabberdctl muc_online_rooms global" it didn't list a single one. Also any wrong command after the base url returned the same response to me. So what am I doing wrong?
edit: I did of course also include the rest module itself:
mod_rest:
allowed_ips:
- "127.0.0.1"