# Aggiungi evento al calendario usando REST API

**URL:** <https://meta.discourse.org/t/add-calendar-event-using-rest-api/307612>\
**Category:** Development\
**Tags:** events, rest-api\
**Created:** [11 Maggio 2024, 12:32am UTC](https://meta.discourse.org/t/add-calendar-event-using-rest-api/307612 "2024-05-11T00:32:21Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![simon](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/simon/32/339122_2.png) [@simon](https://meta.discourse.org/u/simon)\
**Post date:** [11 Maggio 2024, 3:25am UTC](https://meta.discourse.org/t/add-calendar-event-using-rest-api/307612/2 "2024-05-11T03:25:29Z")

</div>

Che ne dici di [creare un argomento o un post](https://docs.discourse.org/#tag/Posts/operation/createTopicPostPM) per l’evento tramite l’API e aggiungere i tag `[event][/event]` al post come valore del suo parametro `raw`?

Il trucco sembra essere che ci deve essere un carattere di nuova riga (`\n`) tra i tag `event` di apertura e chiusura.

Sto usando `\"Content-Type: multipart/form-data\"` nell’esempio seguente perché è più facile che gestire JSON dalla riga di comando. Inoltre, `$api_key` è impostato sul valore di una vera chiave API:

```plaintext
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]'

```

---

_[View the full topic](https://meta.discourse.org/t/add-calendar-event-using-rest-api/307612)._
