When trying to connect the ui with the rasa server, by making a post request with ajax i get the folowing error:
File “/build/lib/python3.6/site-packages/sanic/app.py”, line 920, in handle_request handler, args, kwargs, uri = self.router.get(request) File “/build/lib/python3.6/site-packages/sanic/router.py”, line 407, in get return self._get(request.path, request.method, “”) File “/build/lib/python3.6/site-packages/sanic/router.py”, line 447, in _get raise method_not_supported sanic.exceptions.MethodNotSupported: Method GET not allowed for URL /webhooks/rest/webhook
what you say “the UI”, which UI do you mean ? is it a website with a chat widget? Looking at the error, it seems the server is receiving a GET request instead of a POST. What does your javascript code look like ?
I mean a basic html script with js code embedded and an ajax call to communicate with the rasa server api. Although the error says “Method GET not allowed” the ajax call request has type “POST” (see below)
$.ajax({
url: 'http://XXXXXX.appspot.com/webhooks/rest/webhook', // RASA API
type: 'POST',
headers: {
'Content-Type': 'application/json'
},
data: JSON.stringify({
"sender": "user",
"message": text
}),
dataType: "jsonp",
crossDomain: true,
....
Also except the “Method” error I can see in Google App engine logs also the folowing error:
This error was caused because I implemented an ajax call with dataType:“jsonp” and as I searched on the web; it changes the type from “POST” to “GET”. I changed the datatype to “json” and now I have a “POST” request, but with the CORS error.
My Dockerfile is:
FROM rasa/rasa
ENV BOT_ENV=production
COPY . /var/www
WORKDIR /var/www
RUN rasa --version
RUN python --version
ENTRYPOINT [ "rasa", "run","--debug","--p","8080","--enable-api","--cors","\"*\""]
As you can see I have enable the Allow Origin argument (–cors) for all urls, but still I can’t avoid the CORS problem. Is there any way to check that --cors “*” argument is working properly on the latest version of rasa?
P.S. As I know Curl and Postman do not take into account CORS and so they work properly with my rasa server.
Hi @amn41@Iamhuntingwabbits I am new to this. pls help
I ran this command in my rasa project directory “rasa run -m models --enable-api --cors “*” --debug” and tried to open the URL http://localhost:5005/webhooks/rest/webhook
Getting the attached error.
Kindly please help.
I also tested on the local host for testing purpose. to know whether it is working fine or not , but got the error. which I am attaching the screenshot of it below.