Search code examples
erlangejabberd

Rest call for mod_rest in ejabberd not working


Hello guys in my project I have the JID of sender and receiver and the body of the message. I need to send the message without using any chat client, hence I am using mod_rest so that I can access mod_admin_extra. I configured it with Ejabberd server 14.05 and tried to run the following rest call

[root@centos ~]# wget localhost:5280/rest/ --server-response --post-data 'registered_users localhost'
--2016-06-20 17:03:33--  http://localhost:5280/rest/
Connecting to <<proxy ip>>... connected.
Proxy request sent, awaiting response...
  HTTP/1.0 200 OK
  Content-Type: text/html; charset=utf-8
  Content-Length: 1015
  Connection: close
  Date: Mon, 20 Jun 2016 11:33:33 GMT
Length: 1015 [text/html]
Saving to: “index.html.3”

Where index.html.3 had the following message,

Problem 'error function_clause' occurred executing the command.
Stacktrace: [{ejabberd_commands,'-check_access_commands/5-fun-0-',
                 [{rest,[{registered_users,[all]},{connected_users,[all]}]}],
                 [{file,"src/ejabberd_commands.erl"},{line,372}]},
             {lists,'-filter/2-lc$^0/1-0-',2,[{file,"lists.erl"},{line,1284}]},
             {ejabberd_commands,check_access_commands,5,
                 [{file,"src/ejabberd_commands.erl"},{line,371}]},
             {ejabberd_commands,execute_command,4,
                 [{file,"src/ejabberd_commands.erl"},{line,308}]},
             {ejabberd_ctl,call_command,3,
                 [{file,"src/ejabberd_ctl.erl"},{line,293}]},
             {ejabberd_ctl,try_call_command,3,
                 [{file,"src/ejabberd_ctl.erl"},{line,269}]},
             {ejabberd_ctl,process2,3,
                 [{file,"src/ejabberd_ctl.erl"},{line,218}]},
             {mod_rest,maybe_post_request,3,
                 [{file,"src/mod_rest.erl"},{line,135}]}]

Mod_admin_extra is added in ejabberd configuration file.Is this an issue of command not been identified.If yes the please explain how to add mod_Admin_extra commands in ejabberdctl I am new to erlang so its quite difficult for me to debug hence any help would be beneficial for me and if you guys know any better approach to send message other than using mod_rest please do let me know Thanks alot


Solution

  • I got the issue. The ejabberd_commands.hrl and mod_admin_extra modules of ejabberd 14.05 do not support the commands I needed. Hence I added newer version of both modules and it started working