# 能否通过 API 使用共享草稿？

**URL:** https://meta.discourse.org/t/can-i-use-shared-drafts-with-the-api/265156
**Category:** Support
**Tags:** shared-drafts
**Created:** [2020年一月21日 03:58 UTC](https://meta.discourse.org/t/can-i-use-shared-drafts-with-the-api/265156 "2020-01-21T03:58:57Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![arnaud\_sahuguet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arnaud_sahuguet/32/122538_2.png) [@arnaud\_sahuguet](https://meta.discourse.org/u/arnaud_sahuguet)
#### Post date: [2020年一月21日 03:58 UTC](https://meta.discourse.org/t/can-i-use-shared-drafts-with-the-api/265156/1 "2020-01-21T03:58:57Z")

</div>

此功能是否可通过 API 访问？  
我尝试在我为共享草稿选择的分类中创建一个新主题，但它创建的是普通帖子，而不是共享草稿。  
API 是否支持共享草稿？

---

<div class="post-metadata">

### Author: ![jomaxro](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jomaxro/32/126216_2.png) [@jomaxro](https://meta.discourse.org/u/jomaxro)
#### Post date: [2020年一月21日 04:01 UTC](https://meta.discourse.org/t/can-i-use-shared-drafts-with-the-api/265156/2 "2020-01-21T04:01:51Z")

</div>

任何可以通过用户界面完成的操作，都可以通过 API 完成。不过，我认为我们尚未对此进行文档说明。您需要参考[本指南](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576)来了解如何发出正确的 API 调用。

> [@arnaud\_sahuguet](#):
>
> 我尝试在我为共享草稿选择的类别中创建一个新主题，但它创建的是普通帖子，而不是共享草稿。

这是预期行为，共享草稿类别仍然是一个普通类别，可以在其中创建普通主题。您需要更改所创建内容的类型——即共享草稿，而非新主题。

---

<div class="post-metadata">

### Author: ![arnaud\_sahuguet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arnaud_sahuguet/32/122538_2.png) [@arnaud\_sahuguet](https://meta.discourse.org/u/arnaud_sahuguet)
#### Post date: [2020年一月22日 02:45 UTC](https://meta.discourse.org/t/can-i-use-shared-drafts-with-the-api/265156/3 "2020-01-22T02:45:21Z")

</div>

> [@jomaxro](#):
>
> 本指南

明白了。我将遵循该指南来找出魔法咒语，并分享我的结果。未完待续……

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2023年五月16日 09:52 UTC](https://meta.discourse.org/t/can-i-use-shared-drafts-with-the-api/265156/5 "2023-05-16T09:52:37Z")

</div>

要创建共享草稿，您需要向 `/posts.json` 发送一个 POST 请求，请求的载荷（payload）如下：

```json
{
    "raw": "共享草稿内容",
    "title": "共享草稿标题",
    "category": 31,
    "archetype": "regular",
    "shared_draft": true,
    "draft_key": "new_topic"
}

```

类别必须在 **共享草稿类别** 站点设置中列出。

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [2023年五月16日 09:56 UTC](https://meta.discourse.org/t/can-i-use-shared-drafts-with-the-api/265156/7 "2023-05-16T09:56:33Z")

</div>


