[2019-09-20 12:58:02 +0530] [4668] [ERROR] Exception occurred while handling uri: 'http://localhost:5005/webhooks/rest/webhook'
Traceback (most recent call last):
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\site-packages\sanic\request.py", line 149, in load_json
self.parsed_json = loads(self.body)
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\json\__init__.py", line 349, in loads
s = s.decode(detect_encoding(s), 'surrogatepass')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x91 in position 0: invalid start byte
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\site-packages\sanic\app.py", line 917, in handle_request
response = await response
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\site-packages\rasa\core\channels\channel.py", line 439, in receive
sender_id = await self._extract_sender(request)
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\site-packages\rasa\core\channels\channel.py", line 392, in _extract_sender
return req.json.get("sender", None)
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\site-packages\sanic\request.py", line 143, in json
self.load_json()
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\site-packages\sanic\request.py", line 153, in load_json
raise InvalidUsage("Failed when parsing body as json")
sanic.exceptions.InvalidUsage: Failed when parsing body as json
I’ve used the following code to bring up the server:
rasa run -m models --enable-api --log-file out.log
The model that is running is the model that I get when i run rasa init --no-prompt
Mmm, it’s possible that you have the curly quote ’ instead of the straight one ' and that is messing it up – they’re quite finnicky and I’ve definitely run into that problem when copying a statement from the internet where straight quotes are always rendered as the prettier ones (which are actually completely different characters)!
I took care of all the syntax related errors by typing out the entire code.
Now i get this error
[2019-09-20 15:04:31 +0530] [12188] [ERROR] Exception occurred while handling uri: 'http://localhost:5005/webhooks/rest/webhook'
Traceback (most recent call last):
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\site-packages\sanic\request.py", line 149, in load_json
self.parsed_json = loads(self.body)
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\json\__init__.py", line 354, in loads
return _default_decoder.decode(s)
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\json\decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\json\decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\site-packages\sanic\app.py", line 917, in handle_request
response = await response
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\site-packages\rasa\core\channels\channel.py", line 439, in receive
sender_id = await self._extract_sender(request)
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\site-packages\rasa\core\channels\channel.py", line 392, in _extract_sender
return req.json.get("sender", None)
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\site-packages\sanic\request.py", line 143, in json
self.load_json()
File "d:\softwares\anaconda\anaconda3\envs\cbot\lib\site-packages\sanic\request.py", line 153, in load_json
raise InvalidUsage("Failed when parsing body as json")
sanic.exceptions.InvalidUsage: Failed when parsing body as json
Like the error says, the program failed to parse the string as json.
Step 1 would be to validate your json syntax with a linter. E.g. https://jsonlint.com/