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

error bad request #24

Open
emilianobonassi opened this issue Aug 12, 2014 · 6 comments
Open

error bad request #24

emilianobonassi opened this issue Aug 12, 2014 · 6 comments

Comments

@emilianobonassi
Copy link

Hi, i need your help to understand why i get this error:
"<0.575.0> Processing throwed error {badmatch,{error,bad_request}}
trace: [{mod_restful,handle_rest_request,5,[{file,"src/mod_restful.erl"},{line,187}]},{mod_restful,process,2,[{file,"src/mod_restful.erl"},{line,161}]},{ejabberd_http,process,2,[{file,"src/ejabberd_http.erl"},{line,355}]},{ejabberd_http,process_request,1,[{file,"src/ejabberd_http.erl"},{line,461}]},{ejabberd_http,process_header,2,[{file,"src/ejabberd_http.erl"},{line,287}]},{ejabberd_http,receive_headers,1,[{file,"src/ejabberd_http.erl"},{line,181}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]
"
The configuration is:
mod_restful:
api:
- path: ["admin"]
module: mod_restful_admin
params:
allowed_commands: [status]

and i send a post request with command argument and none args.
Thank you in advance for your help.

@jadahl
Copy link
Owner

jadahl commented Aug 12, 2014

Looks like you get the error "bad request" which here seems to mean the content type of the post request is not "application/json".

@emilianobonassi
Copy link
Author

Thank for your answer. You are right, I've just corrected my code and now
it works perfectly.

I've another question, I need to execute all possible commands available on
ejabberdctl.
I saw that in your code you deny the request if allowed commands options is
undefined. For my purposes I modified it and instead of deny now it allows.
I looked for another solution, like a wildcard in allowed command but I
didn't find nothing.
Do you know a solution more elegant/clear without modifing your code?

I'm looking forward to hearing from you!
Best regards,
Emiliano

On Tue, Aug 12, 2014 at 1:15 PM, Jonas Ådahl notifications@github.com
wrote:

Looks like you get the error "bad request" which here seems to mean the
content type of the post request is not "application/json".


Reply to this email directly or view it on GitHub
#24 (comment).


Emiliano Bonassi
AssBenaz.COM
Via Alpamayo 13
20854 Vedano Al Lambro (MI) IT
Mob/Cell: +39 349 49 93 036

VAT/P.I.: IT06275970967

NOTICE TO RECIPIENTS: The information contained in and accompanying this
communication may be confidential, subject to legal privilege, or otherwise
protected from
disclosure, and is intended solely for the use of the intended
recipient(s). If you are not
the intended recipient of this communication, please delete and destroy all
copies in your
possession, notify the sender that you have received this communication in
error, and note that
any review or dissemination of, or the taking of any action in reliance on,
this communication is
expressly prohibited.

"INFORMAZIONE PER IL RICEVENTE: Le informazioni che sono contenute o che
accompagnano questa comunicazione potrebbero essere riservate, coperte da
segreto professionale, o altrimenti protette da altre restrizioni alla loro
divulgazione, e sono destinate esclusivamente alle persone alle quali
questa comunicazione é indirizzata. Se questa comunicazione non é
indirizzata a Voi, siete pregati di distruggerne tutte le copie in Vostro
possesso, di notificarci che avete ricevuto questa comunicazione per
errore, e di considerare che sono espressamente vietate la lettura, la
diffusione o la distribuzione totale o parziale di questa comunicazione,
nonché l'agire sulla base di (informazioni contenute in) questa
comunicazione.

@jadahl
Copy link
Owner

jadahl commented Aug 14, 2014

Either you list all possible commands in the configuration, or you need to add a separate option like "allow_all" and modify mod_restful_admin.erl to deal with that option.

@emilianobonassi
Copy link
Author

Thank you for the suggestion.
I will consider it and let you know my decision.

If you want then I can send you my patch, are you interested in?

Best regards,
Emiliano

On Thu, Aug 14, 2014 at 1:18 PM, Jonas Ådahl notifications@github.com
wrote:

Either you list all possible commands in the configuration, or you need to
add a separate option like "allow_all" and modify mod_restful_admin.erl to
deal with that option.


Reply to this email directly or view it on GitHub
#24 (comment).


Emiliano Bonassi
AssBenaz.COM
Via Alpamayo 13
20854 Vedano Al Lambro (MI) IT
Mob/Cell: +39 349 49 93 036

VAT/P.I.: IT06275970967

NOTICE TO RECIPIENTS: The information contained in and accompanying this
communication may be confidential, subject to legal privilege, or otherwise
protected from
disclosure, and is intended solely for the use of the intended
recipient(s). If you are not
the intended recipient of this communication, please delete and destroy all
copies in your
possession, notify the sender that you have received this communication in
error, and note that
any review or dissemination of, or the taking of any action in reliance on,
this communication is
expressly prohibited.

"INFORMAZIONE PER IL RICEVENTE: Le informazioni che sono contenute o che
accompagnano questa comunicazione potrebbero essere riservate, coperte da
segreto professionale, o altrimenti protette da altre restrizioni alla loro
divulgazione, e sono destinate esclusivamente alle persone alle quali
questa comunicazione é indirizzata. Se questa comunicazione non é
indirizzata a Voi, siete pregati di distruggerne tutte le copie in Vostro
possesso, di notificarci che avete ricevuto questa comunicazione per
errore, e di considerare che sono espressamente vietate la lettura, la
diffusione o la distribuzione totale o parziale di questa comunicazione,
nonché l'agire sulla base di (informazioni contenute in) questa
comunicazione.

@jadahl
Copy link
Owner

jadahl commented Aug 14, 2014

Feel free to send any patch you write.

@emilianobonassi
Copy link
Author

Great!

On Thu, Aug 14, 2014 at 1:31 PM, Jonas Ådahl notifications@github.com
wrote:

Feel free to send any patch you write.


Reply to this email directly or view it on GitHub
#24 (comment).


Emiliano Bonassi
AssBenaz.COM
Via Alpamayo 13
20854 Vedano Al Lambro (MI) IT
Mob/Cell: +39 349 49 93 036

VAT/P.I.: IT06275970967

NOTICE TO RECIPIENTS: The information contained in and accompanying this
communication may be confidential, subject to legal privilege, or otherwise
protected from
disclosure, and is intended solely for the use of the intended
recipient(s). If you are not
the intended recipient of this communication, please delete and destroy all
copies in your
possession, notify the sender that you have received this communication in
error, and note that
any review or dissemination of, or the taking of any action in reliance on,
this communication is
expressly prohibited.

"INFORMAZIONE PER IL RICEVENTE: Le informazioni che sono contenute o che
accompagnano questa comunicazione potrebbero essere riservate, coperte da
segreto professionale, o altrimenti protette da altre restrizioni alla loro
divulgazione, e sono destinate esclusivamente alle persone alle quali
questa comunicazione é indirizzata. Se questa comunicazione non é
indirizzata a Voi, siete pregati di distruggerne tutte le copie in Vostro
possesso, di notificarci che avete ricevuto questa comunicazione per
errore, e di considerare che sono espressamente vietate la lettura, la
diffusione o la distribuzione totale o parziale di questa comunicazione,
nonché l'agire sulla base di (informazioni contenute in) questa
comunicazione.

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