# 当我尝试获取API时，由于文档不足，出现了两个ID。

**URL:** https://meta.discourse.org/t/there-are-2-ids-when-i-try-to-get-api-in-case-of-lack-documentation/214844
**Category:** Development
**Tags:** rest-api
**Created:** [2022年一月14日 11:07 UTC](https://meta.discourse.org/t/there-are-2-ids-when-i-try-to-get-api-in-case-of-lack-documentation/214844 "2022-01-14T11:07:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![cmdntd](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cmdntd/32/192008_2.png) [@cmdntd](https://meta.discourse.org/u/cmdntd)
#### Post date: [2022年一月14日 11:07 UTC](https://meta.discourse.org/t/there-are-2-ids-when-i-try-to-get-api-in-case-of-lack-documentation/214844/1 "2022-01-14T11:07:50Z")

</div>

> 我尝试按照 Sam 在 [如何逆向工程 Discourse API](https://meta.discourse.org/t/how-to-reverse-engineer-the-discourse-api/20576) 中的说明进行操作  
> 但它显示了 2 个 ID，这让我不知道接下来该怎么做

当我尝试更新私信时，它有不同的 2 个 ID：

1. 私信的 ID
2. 数字较大的 ID（例如用于编辑私信的 ID）

 ![6jLZwKRZd3](https://global.discourse-cdn.com/meta/original/3X/d/e/de196de5f6187c4c0cd01b28d9d083d2cff4acbd.png)

当我测试发送 PUT 请求时，私信的 ID 只能更改标题。并且无法通过“raw”更改消息详情

**消息详情似乎必须通过新的编辑 ID 来更改**  
**我不知道如何获取帖子的第二个 ID（图片中的 1846）**

你能解释一下这个问题吗？

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [2022年一月14日 14:37 UTC](https://meta.discourse.org/t/there-are-2-ids-when-i-try-to-get-api-in-case-of-lack-documentation/214844/2 "2022-01-14T14:37:27Z")

</div>

> [@cmdntd](#):
>
> - 私信的ID

那是 `topic.id`

> [@cmdntd](#):
>
> 1. ID 较大的那个（比如编辑私信的ID）

那是 `post.id`

> [@cmdntd](#):
>
> 当我测试发送PUT请求时，私信的ID只能修改标题。无法通过“raw”修改消息详情。

标题是主题的一部分，`raw` 是帖子的部分。如果你仔细查看帖子，你会看到一个 `topic_id` 字段，其中包含你称之为私信ID的数字。

你可以在这里查看：[There are 2 IDs when I try to get API, in case of lack documentation](https://meta.discourse.org/t/there-are-2-ids-when-i-try-to-get-api-in-case-of-lack-documentation/214844.json) （这是这个主题，但与PM相同），然后你会看到：

 ![image](https://global.discourse-cdn.com/meta/original/3X/2/7/2797446e89d14d74c994d04cdc831b36b6c0f501.png)

所以，`post_id` 是你用来将更改 POST 到 `raw` 的内容。`topic_id` 是你用来更改标题的地方。

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2022年二月13日 14:37 UTC](https://meta.discourse.org/t/there-are-2-ids-when-i-try-to-get-api-in-case-of-lack-documentation/214844/3 "2022-02-13T14:37:56Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
