Getting "invalid_access" error when trying to GET/PUT a Topic Category

Hello, I have a rails app which doesnt allow my Admin User with the configured API key to GET/PUT category in a topic.

When making the API key, I added it for “All Users”. Anyway, the topic I’m trying to work with was made by the same user whose credentials I’m using.

It doesn’t really make sense to me. This is the response:

{"errors"=>["You are not permitted to view the requested resource."], "error_type"=>"invalid_access"}

This is my code:

endpoint = "/t/604.json" #It is topic number 604
username = "Instagram_Fans" #Admin user with API key. Also OP
USERNAME = "Instagram_Fans"
BASE_URL = "http://localhost:3002" #Discourse development URL
API_KEY = "****"
    def self.categorize_topic_as_deleted(endpoint)
      body = {"category_id" => 79} #Category I'm trying to use for the topic
      username ||= USERNAME
      response = Faraday.put(BASE_URL + endpoint) do |req|
        req.body = body
        req.headers['Api-Key'] = API_KEY
        req.headers['Api-Username'] = username