Search code examples
restpostmancrudrasarasa-x

Invalid story format failed to parse story while posting Rasa X Http API


I am trying to create a story using POST in Postman tool and below is my story format . I am using below format because in GET request I got the story in the same format.

{
        "id": 65,
        "name": "interactive_story_65",
        "story": "35 interactive_story_65\n* emp_info\n    - utter_employee",
        "annotation": {
            "user": "me",
            "time": 1597919151.8836874962
        },
        "filename": "data\\stories.md"
    }

But, I am getting below error:

{
    "version": "0.31.0",
    "status": "failure",
    "message": "Failed to parse story.",
    "reason": "StoryParseError",
    "details": "Invalid story format. Failed to parse '## {\r\n        \"id\": 65,\r\n        \"name\": \"interactive_story_65\",\r\n        \"story\": \"## interactive_story_65\\n* emp_info\\n    - utter_employee\",\r\n        \"annotation\": {\r\n            \"user\": \"me\",\r\n            \"time\": 1597919151.8836874962\r\n        },\r\n        \"filename\": \"data\\\\stories.md\"\r\n    }'",
    "help": null,
    "code": 400
}

Attached is below screenshot:

enter image description here

Please help.


Solution

  • This endpoint is actually expecting plain markdown, with text/x-markdown as the content-type header. If you look closely at the docs, you'll see that you're using the response schema as the request schema - I did that too at first. The request schema is just a markdown string e.g.

    curl --request PUT \
      --url http://localhost:5002/api/stories \
      --header 'authorization: Bearer <Token>' \
      --header 'content-type: text/x-markdown' \
      --data '## greet
        * greet
            - utter_greet\n'