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

mod_restful on ejabberd_16.01 - Problem with module mod_restful #30

Open
iharush opened this issue Feb 24, 2016 · 3 comments
Open

mod_restful on ejabberd_16.01 - Problem with module mod_restful #30

iharush opened this issue Feb 24, 2016 · 3 comments

Comments

@iharush
Copy link

iharush commented Feb 24, 2016

hi
i am working on ejabberd_16.01 and i'm facing problems using mod_restful.

ejabberd.yml:

listen:
  -
    port: 8088
    ip: "::"
    module: ejabberd_http
    request_handlers:
      "/api": mod_restful
modules:
  mod_restful:
    api:
      - 
        path: ["admin"]
        module: mod_restful_admin
        params:
          key: "secret" ## if you want to use basic auth, you need to remove this line
          allowed_commands: [srg_create, srg_user_add, status, registered_users]

I added the module:

> sudo /opt/ejabberd-16.01/bin/ejabberdctl module_install mod_restful
src/mod_restful_admin.erl:63: Warning: behaviour en_restful_api undefined
src/mod_restful_register.erl:32: Warning: behaviour en_restful_api undefined
ok

when I call :

POST /api/admin HTTP/1.1
Host: 173.39.250.116:8088
Content-Type: application/json
Cache-Control: no-cache

{"key":"secret", "command":"status", "args":[]}

I get :

<?xml version='1.0'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 
    xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
    <head>
        <meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
    </head>
    <body>
        <h1>401 Unauthorized</h1>
    </body>
</html>

any idea what am I missing?

Thanks
Itay

@iharush iharush changed the title mod_restful on ejabberd_16.01 - Problem starting the module mod_restful mod_restful on ejabberd_16.01 - Problem with module mod_restful Feb 24, 2016
@iharush
Copy link
Author

iharush commented Feb 24, 2016

one more pice of info, the ejabberd log :

2016-02-24 12:25:28.990 [info] <0.619.0>@ejabberd_listener:accept:333 (#Port<0.15943>) Accepted connection 10.149.215.173:59829 -> 192.168.0.26:8088
2016-02-24 12:25:28.991 [info] <0.623.0>@ejabberd_http:init:158 started: {gen_tcp,#Port<0.15943>}
2016-02-24 12:25:28.991 [error] <0.623.0> Processing throwed error {bad match,false}
trace: [{mod_restful,handle_request,3,[{file,"src/mod_restful.erl"},{line,179}]},{mod_restful,process,2,[{file,"src/mod_restful.erl"},{line,161}]},{ejabberd_http,process,5,[{file,"src/ejabberd_http.erl"},{line,363}]},{ejabberd_http,process_request,1,[{file,"src/ejabberd_http.erl"},{line,451}]},{ejabberd_http,process_header,2,[{file,"src/ejabberd_http.erl"},{line,291}]},{ejabberd_http,parse_headers,1,[{file,"src/ejabberd_http.erl"},{line,211}]},{ejabberd_http,init,2,[{file,"src/ejabberd_http.erl"},{line,164}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,237}]}]

any ideas?

@jadahl
Copy link
Owner

jadahl commented Feb 26, 2016

You need to provide a valid hostname via the HTTP request. 173.39.250.116 is the hostname you provide in your request, but I'm guessing this is not a hostname you have configured your server to use.

@iharush
Copy link
Author

iharush commented Feb 28, 2016

That solved my problem.

Thanks!

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