jadahl / mod_restful

RESTful interface to ejabberd
84 stars 34 forks source link

error bad request #24

Open emilianobonassi opened 10 years ago

emilianobonassi commented 10 years ago

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:

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

jadahl commented 10 years ago

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 commented 10 years ago

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 https://github.com/jadahl/mod_restful/issues/24#issuecomment-51901160.


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 commented 10 years ago

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 commented 10 years ago

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 https://github.com/jadahl/mod_restful/issues/24#issuecomment-52171467.


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 commented 10 years ago

Feel free to send any patch you write.

emilianobonassi commented 10 years ago

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 https://github.com/jadahl/mod_restful/issues/24#issuecomment-52172413.


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.