Ejabberd Mod HTTP API localhost access

Hi,
I am just getting started with ejabberd and done a local setup in Ubuntu 16.04 LTS. I want to use mod_http_api without any authentication Here is my current configuration done in ejabberd.yml

# Enable Ejabberd Rest API
listen:
  -
    port: 5281
    module: ejabberd_http
    request_handlers:
      "/api": mod_http_api
    
    api_permissions:
      "API used from localhost allows all calls":
        - who:
          - ip: "127.0.0.1/0"
        - what:
          - "*"
          - "!stop"
          - "!start" 

When i do a request via Postman at http://localhost:5281/api/connected_users_info
I get following response:

400 Bad Request

The ejabberd debug logs show following error:

2017-04-11 12:13:30.262 [info] <0.456.0>@ejabberd_listener:accept:333 (#Port<0.14346>) Accepted connection 127.0.0.1:48932 -> 127.0.0.1:5281
2017-04-11 12:13:30.263 [debug] <0.459.0>@ejabberd_http:init:154 S: [{[<<"api">>],mod_http_api}]
2017-04-11 12:13:30.263 [info] <0.459.0>@ejabberd_http:init:158 started: {gen_tcp,#Port<0.14346>}
2017-04-11 12:13:30.271 [debug] <0.459.0>@ejabberd_http:process_header:281 (#Port<0.14346>) http query: 'POST' <<"/api/connected_users_info">>
2017-04-11 12:13:30.271 [debug] <0.459.0>@ejabberd_http:extract_path_query:395 client data: <<"{\r\n}">>
2017-04-11 12:13:30.271 [debug] <0.459.0>@ejabberd_http:process:353 [<<"api">>,<<"connected_users_info">>] matches [<<"api">>]
2017-04-11 12:13:30.273 [debug] <0.459.0>@mod_http_api:process:169 Bad Request: undef

There is nothing specified here so i am not sure what's the actual error. Can someone guide me what's going wrong here. I even tried with X-Admin: true header but it didn't worked

Did you enable mod_http_api

Did you enable mod_http_api in the Modules section in your ejabberd configuration file?

And also, I see something suspicious in your example configuration: it seems as if you included api_permissions inside the listen section. But in reality it must be outside.

Syndicate content