Rasa version: 1.1.4
Rasa X version (if used & relevant): 0.19.5
Python version: 3.6.9
Operating system (windows, osx, ...): official docker containers
Issue:
Replacing Stories, using PUT /api/stories
doesnt replace the stories and return an Error: Invalid response type
Error (including full traceback):
rasa-x_1 | [2019-07-16 05:09:14 +0000] [22] [ERROR] Invalid response object for url b'/api/stories', Expected Type: HTTPResponse, Actual Type: <class 'NoneType'>
rasa-x_1 | [2019-07-16 05:09:14 +0000] [22] [ERROR] Exception occurred while handling uri: 'http://----/api/stories'
rasa-x_1 | Traceback (most recent call last):
rasa-x_1 | File "/usr/local/lib/python3.6/site-packages/sanic/server.py", line 417, in write_response
rasa-x_1 | response.output(
rasa-x_1 | AttributeError: 'NoneType' object has no attribute 'output'
Command or request that led to error:
PUT /api/stories using Postman 2
body:
[
{
"story": "## anything else?\n - utter_anything_else\n* enter_data\n - utter_not_sure\n - utter_possibilities",
"id": "34",
"annotation": {
"user": "me",
"time": 0,
"name": "anything else?"
},
}
]
I tried it recently and it worked, you should be using a stories md file for that endpoint - have you tried that?
@aklad the documentation for this endpoint states that the request body is a string containing text/markdown. It does not state that it is a string containing a filename.
All of these fail for me. Some return 200 with a response of [].
curl -XPUT -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://${HOST}:${PORT}/api/stories -d 'test.md'
curl -XPUT -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://${HOST}:${PORT}/api/stories -d '[{"filename": "test.md"}]'
curl -XPUT -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://${HOST}:${PORT}/api/stories -d 'aml_faq.md'
curl -XPOST -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://${HOST}:${PORT}/api/stories -d 'aml_faq.md'
curl -XPOST -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://${HOST}:${PORT}/api/stories -d '[{"filename":"aml_faq.md"}]'
curl -XPUT -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://${HOST}:${PORT}/api/stories -d '[]'
curl -XPOST -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://${HOST}:${PORT}/api/stories -d '"## my title\n* aml_2\n - utter_aml_2\n - dynamic_form"'
curl -XPOST -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://${HOST}:${PORT}/api/stories -d '{ "story": "## my title\n* aml_2\n - utter_aml_2\n - dynamic_form" }'
curl -XPOST -H 'Accept: application/json' -H "Authorization: Bearer ${TOKEN}" http://${HOST}:${PORT}/api/stories -d '[ { "story": "## my title\n* aml_2\n - utter_aml_2\n - dynamic_form" } ]'
I've tried the same with Postman and it returns [] with status 200.
This is a guessing game based on the API docs. I've tried innumerable permutations of the PUT & POST endpoints that aren't working for me. How about some working examples for the API or even one example CURL command that works for each endpoint???
the PUT command with the flag --data-binary @filename.md should work
Thanks for the quick response. That was it.
cool, we'll look into updating the docs with these kinds of examples. I'll close this particular issue for now
@akelad It's not just a matter of adding examples, there's a bug in the documentation for the API that needs to be fixed. The API docs state that POST for stories (and other calls) takes a string containing markdown which is incorrect.
@rgstephens sorry for getting back to you so late, i've been away - we're gonna be reworking the API page in general, so will incorporate that. Thanks for letting us know.
Most helpful comment
@rgstephens sorry for getting back to you so late, i've been away - we're gonna be reworking the API page in general, so will incorporate that. Thanks for letting us know.