I’ve been searching for hours how to use REST API to add calendar event to a topic and unfortunately, i couldn’t find an answer.
I’ve created a category calendar and could display my topic event created manually but could not handle to automate the topic event creation when i add a topic using REST API.
I’ve found “discourse-post-events/events.json” but when i tried this API, i get “Not Found”. I suppose it’s because there is the need for event ids and i don’t know how to create them.
How about just create a topic or post for the event via the API and add the [event][/event] tags to the post as the value of its raw parameter?
The trick seems to be that there has to be a newline character (\n) between the opening and closing event tags.
I’m using "Content-Type: multipart/form-data" in the example below because it’s easier than dealing with JSON from the command line. Also $api_key is set to the value of an actual API Key:
curl -X POST "http://localhost:4200/posts.json" \
-H "Api-Key: $api_key" \
-H "Api-Username: scossar" \
-H "Content-Type: multipart/form-data" \
-F title="Can I create an event via the API?" \
-F category=6 \
-F raw='[event start="2024-05-10 20:00" status="public" timezone="America/Vancouver" end="2024-05-10 21:30" allowedGroups="trust_level_0"]\n[/event]'
When i get off event declaration and put alternative description, my forum gets updated but as soon as i put event declaration, i get Unprocessable Entity.