Skip to content

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

@iharush

Description

@iharush

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions