Rasa bot bad request and cors proxy issue

(nadeem choudhary) #1

Rasa core version 13.7 nlu version 14.6 os windows 10 python version 3.5

i created rasa chatbot and trained nlu as well as dialogue model.i have manage to run this bot successfully in the console but when we try to run this as the http server we get a cors proxy error as follows the command we used to run the server is

  • python -m rasa_core.run -d models/dialogue -u models/nlu/default/stem_nlu --enable_api --credentials credentials.yml --cors “*” i have also tried
  • python -m rasa_core.run -d models/dialogue -u models/nlu/default/stem_nlu --enable_api --credentials credentials.yml --cors “*” -c rest with no luck i tried sending request through browser and postman to localhost:5005/conversations/deafult/respond i got { “code”: 400, “details”: { “in”: “query”, “parameter”: “query” }, “help”: null, “message”: “Missing the message parameter.”, “reason”: “InvalidParameter”, “status”: “failure”, “version”: “0.13.7” }

and also tried localhost:5005/webhooks/rest/webhook i got Bad Request The browser (or proxy) sent a request that this server could not understand. bot server shows options 127.0.0.1 - - [2019-04-15 17:34:30] “OPTIONS /webhooks/rest/webhook HTTP/1.1” 200 306 0.001031 then post request 127.0.0.1 - - [2019-04-15 17:34:30] “POST /webhooks/rest/webhook HTTP/1.1” 400 352 0.000000

and we have used script as follows

$(document).ready(function(){

$("#button").click(function(){
var message=document.getElementById("message").value;

console.log(message); $.ajaxSetup({ headers: {“Content-Type”: “application/json”} });

$.ajax({ url: “http://localhost:5005/webhooks/rest/webhook”, type: “POST”, data: ‘{ “sender”: message}’ }).done(function(data) {

    console.log(data);
})

pls resolve soon

0 Likes

(Mohan Kumar G) #2

@nadeem i guess you need to have endpoints.yml in your directory and pass that to cmd line using “–endpoints endpoints.yml” the content of yml as below

action_endpoint:
  url: "http://localhost:5055/webhook"
0 Likes

(nadeem choudhary) #3

i tried with endpoint still getting the same code: 400 bad request error 127.0.0.1 - - [2019-04-17 17:09:15] “OPTIONS /webhooks/rest/webhook HTTP/1.1” 200 306 0.000000 127.0.0.1 - - [2019-04-17 17:09:15] “POST /webhooks/rest/webhook HTTP/1.1” 400 352 0.001992

0 Likes

(Srikar) #4

Have you tried including the CORS policy in the ajax headers? Before that, download CORS extension on chrome and try enabling it, see if you’re still getting the error with CORS enabled?

0 Likes