# Rest API om eigenaren toe te voegen werkt niet meer

**URL:** https://meta.discourse.org/t/rest-api-to-add-owners-has-stopped-working/348591
**Category:** Support
**Tags:** rest-api
**Created:** [23 januari 2025 om 12:08 UTC](https://meta.discourse.org/t/rest-api-to-add-owners-has-stopped-working/348591 "2025-01-23T12:08:30Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Nikki\_Locke](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nikki_locke/32/146184_2.png) [@Nikki\_Locke](https://meta.discourse.org/u/Nikki_Locke)
#### Post date: [23 januari 2025 om 12:08 UTC](https://meta.discourse.org/t/rest-api-to-add-owners-has-stopped-working/348591/1 "2025-01-23T12:08:30Z")

</div>

I used to use the rest api to update the owners of groups. This now seems to have stopped working (though the groups definitely exist):

```plaintext
Method: PUT, RequestUri: 'https://forums.mysite.uk/admin/groups/1949/owners', Version: 1.1, Content: System.Net.Http.FormUrlEncodedContent, Headers:
{
  Api-Key: <redacted>
  Api-Username: admin
  Accept: application/json
  User-Agent: BasecampGatewayLive
  Content-Type: application/x-www-form-urlencoded
}:{
  "group": {
    "usernames": "kay"
  }
}
StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
  Server: nginx/1.22.1
  Date: Thu, 23 Jan 2025 02:03:44 GMT
  Transfer-Encoding: chunked
  Connection: keep-alive
  Vary: Accept-Encoding
  Vary: Accept
  X-Request-ID: 8e5dcf66-c4e0-4d4f-a382-dacb774691c3
  X-Runtime: 0.004369
  Strict-Transport-Security: max-age=31536000; includeSubDomains
  Content-Type: application/json; charset=utf-8
}
{"errors":["The requested URL or resource could not be found."],"error_type":"not_found"}

```

This used to work fine, but a Discourse upgrade seems to have broken it. As this api is not included in the Discourse API page, I’m not sure how to find out what has changed.

---

<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: [23 januari 2025 om 12:32 UTC](https://meta.discourse.org/t/rest-api-to-add-owners-has-stopped-working/348591/2 "2025-01-23T12:32:44Z")

</div>

> [@Nikki\_Locke](#):
>
> As this api is not included in the Discourse API page

Many endpoints aren’t documented, but you can [Reverse engineer the Discourse API](https://meta.discourse.org/t/reverse-engineer-the-discourse-api/20576) easily.

For me, the request works on the latest Discourse version:

 ![This image shows an API response interface displaying a successful JSON output with an "OK" status and a message indicating users named "coco" have been found. (Captioned by AI)](https://global.discourse-cdn.com/meta/original/4X/1/0/8/10858c8752b227674447f4ac47160efe657f2e4c.png)

---

<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: [23 januari 2025 om 15:29 UTC](https://meta.discourse.org/t/rest-api-to-add-owners-has-stopped-working/348591/3 "2025-01-23T15:29:46Z")

</div>

My guess is that your API key is no longer valid.

---

<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: [23 januari 2025 om 16:32 UTC](https://meta.discourse.org/t/rest-api-to-add-owners-has-stopped-working/348591/4 "2025-01-23T16:32:21Z")

</div>

I thought about that, but an invalid key or username normally returns a 403, not a 404 🤷

---

<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: [23 januari 2025 om 16:34 UTC](https://meta.discourse.org/t/rest-api-to-add-owners-has-stopped-working/348591/5 "2025-01-23T16:34:17Z")

</div>

I found the issue:

> [@Nikki\_Locke](#):
>
> `https://forums.mysite.uk/admin/groups/1949/owners`

The correct URL is `https://forums.mysite.uk/groups/1949/owners`, without the `/admin/`.

---

<div class="post-metadata">

### Author: ![supermathie](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/supermathie/32/507518_2.png) [@supermathie](https://meta.discourse.org/u/supermathie)
#### Post date: [23 januari 2025 om 16:53 UTC](https://meta.discourse.org/t/rest-api-to-add-owners-has-stopped-working/348591/6 "2025-01-23T16:53:48Z")

</div>

> [@Nikki\_Locke](#):
>
> `application/x-www-form-urlencoded`

> [@Nikki\_Locke](#):
>
> ```plaintext
> {
> "group": {
> "usernames": "kay"
> }
> }
> 
> ```

You’ll also want to tell the server you’re sending json, not a form.

---

<div class="post-metadata">

### Author: ![Nikki\_Locke](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/nikki_locke/32/146184_2.png) [@Nikki\_Locke](https://meta.discourse.org/u/Nikki_Locke)
#### Post date: [14 april 2025 om 11:14 UTC](https://meta.discourse.org/t/rest-api-to-add-owners-has-stopped-working/348591/7 "2025-04-14T11:14:26Z")

</div>

I just noticed I hadn’t thanked everyone for solving my problem. Sorry, and many thanks!

---

<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: [14 mei 2025 om 11:14 UTC](https://meta.discourse.org/t/rest-api-to-add-owners-has-stopped-working/348591/8 "2025-05-14T11:14:50Z")

</div>

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