안녕하세요, 제 Rails 앱에서 설정된 API 키를 가진 관리자 사용자로 특정 토픽의 카테고리를 GET/PUT할 수 없습니다.
API 키를 생성할 때 "All Users"에 추가했습니다. 그런데 작업하려는 토픽은 제가 현재 사용하고 있는 자격 증명의 사용자(즉, 해당 관리자)가 만든 것입니다.
이해가 되지 않습니다. 응답 내용은 다음과 같습니다:
{"errors"=>["You are not permitted to view the requested resource."], "error_type"=>"invalid_access"}
제 코드는 다음과 같습니다:
endpoint = "/t/604.json" #토픽 번호 604
username = "Instagram_Fans" #API 키를 가진 관리자 사용자. 또한 OP(원글 작성자)
USERNAME = "Instagram_Fans"
BASE_URL = "http://localhost:3002" #Discourse 개발 URL
API_KEY = "****"
def self.categorize_topic_as_deleted(endpoint)
body = {"category_id" => 79} #토픽에 사용하려는 카테고리
username ||= USERNAME
response = Faraday.put(BASE_URL + endpoint) do |req|
req.body = body
req.headers['Api-Key'] = API_KEY
req.headers['Api-Username'] = username
end
handle_response(response)
end