API Error: You are not permitted to view the requested resource

現在、同じ問題に直面している方はいますか?API を使おうとして 2 日間試していますが、毎回同様のエラーが発生します。手順を見落としているのか、それとも何かが変更されたのか分かりません。

system ユーザー用に新しい API キーを作成しました。また、すべてのユーザー用に API キーを作成し、その後で管理者アカウントを使用することも試みました。

discourse_api Ruby gem を使用した場合:

DiscourseApi::UnauthenticatedError ({"errors"=>["You are not permitted to view the requested resource. The API username or key is invalid."], "error_type"=>"invalid_access"})

別の投稿から以下のコードも試しました:

require 'net/http'
require 'uri'

INSTANCE_URL = 'https://forum.example.com/admin/users/list/all.json?email=user@example.com'
API_USERNAME = 'system'
API_KEY = 'a_new_api_key_here'

def send_request
  url = URI.parse(INSTANCE_URL)
  request = Net::HTTP::Get.new(url.path)
  request.set_form_data({'api_username' => API_USERNAME, 'api_key' => API_KEY})
  http = Net::HTTP.new(url.host, url.port)
  response = http.request(request)

  if response.code == '200'
    puts "Success!"
  else
    puts "Error"
    puts response.code
  end
end

send_request # 400

また、api_username と api_key をフォームデータに含めて生リクエストを送信する方法も試しましたが、404 エラーが発生しました。

メールアドレスのリストを読み込み、ユーザー名を取得し、その後でそのユーザーをすべての Discourse メール購読から解除するスクリプトを作成しようとしています。