# APIで404エラーが頻発しています

**URL:** <https://meta.discourse.org/t/api-is-throwing-404-errors/335647>\
**Category:** Product Support\
**Created:** [2024 年 11 月 11 日午後 7:17 UTC](https://meta.discourse.org/t/api-is-throwing-404-errors/335647 "2024-11-11T19:17:33Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![lmno](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lmno/32/463544_2.png) [@lmno](https://meta.discourse.org/u/lmno)\
**Post date:** [2024 年 11 月 11 日午後 7:17 UTC](https://meta.discourse.org/t/api-is-throwing-404-errors/335647/1 "2024-11-11T19:17:33Z")

</div>

こんにちは、Discourse コミュニティの皆様、

現在、Discourse API エンドポイント、特にユーザーの一時停止に関連する問題に直面しており、皆様からの支援やガイダンスをいただければ幸いです。

### 問題の概要

1. **404 Not Found** ：

2. **予期しない HTML レスポンス** ：

3. **API キーと権限** ：

### リクエスト例

#### `curl` 例

```bash
curl -X PUT "https://your-discourse-domain.com/admin/users/15/suspend.json" \
-H "Api-Key: [REDACTED_API_KEY]" \
-H "Api-Username: system" \
-H "Content-Type: application/json" \
-d '{"suspend_until": "2024-12-31", "reason": "Violation of community guidelines"}'

```

#### PowerShell 例

```powershell
# Discourse でユーザーを一時停止するための PowerShell スクリプト

$baseUrl = "https://your-discourse-domain.com"
$userId = 15
$apiKey = "[REDACTED_API_KEY]"
$apiUsername = "system"
$suspendUntil = "2024-12-31"
$reason = "Violation of community guidelines"

$headers = @{
    "Api-Key" = $apiKey
    "Api-Username" = $apiUsername
    "Content-Type" = "application/json"
}

$body = @{
    suspend_until = $suspendUntil
    reason = $reason
} | ConvertTo-Json

$endpoint = "$baseUrl/admin/users/$userId/suspend.json"

try {
    $response = Invoke-RestMethod -Uri $endpoint -Method Put -Headers $headers -Body $body -ErrorAction Stop
    Write-Host "User suspended successfully!" -ForegroundColor Green
} catch {
    Write-Host "Error suspending user:" -ForegroundColor Red
    Write-Host $_.Exception.Message
}

```

### 追加情報

- **Discourse バージョン** ：3.4.0.beta3
- **実施したトラブルシューティング手順** ：
  - `User-Agent` や `Referer` を含むリクエストヘッダーを調整しましたが、効果はありませんでした。

* * *

これらの問題の解決に役立つ洞察や提案があれば、大いに感謝いたします。事前に時間とサポートをいただきありがとうございます！

よろしくお願いいたします。  
Ross

---

_[View the full topic](https://meta.discourse.org/t/api-is-throwing-404-errors/335647)._
