API GET for Category User notification_level

I see discussion about setting notification_level via the API. What about reading values?

For example, I can set a value with:

PUT {{base_url}}/category/14/notifications.json?api_key={{api_key}}&api_username={{api_username}}&notification_level=3

How can I read that same value back?

Have a look at How to reverse engineer the Discourse API visit your profile page on the tab that shows it, its in one of the user json payloads.

2 Likes

Normally reversing out the API has worked for me, but for some reason this time I don’t see it.

From a user’s profile page (/u/user_name/summary) I see the /u/user_name/summary.json payload, but don’t see anything in there about notification_level’s there.

Clicking on the Preferences tab loads /user-badges/user_name.json, also no notification_level.

Clicking on Categories does not seem to load any json payload.

Reloading the page from /u/km_admin/preferences/categories loads \u\user_name.json. That one has all the group notification_level settings, but nothing about category settings.

The user’s category notification level is also accessed by Discourse at \c\category_name, but I don’t see it returned there either, unless it’s called something without the string notific … in it, as all I’m seeing returned there are notification levels for each returned topic.

Safe to assume the content.css, mini-profiler results, and poll payloads can be ignored?

A GET to https://meta.discourse.org/categories.json contains:

{
  "category_list": {
    "categories": [
      {
        "notification_level": 1,
        ...
      },
    ]
  }
}
4 Likes

It finally occurred to me: /categories.json > notification_level is for the logged in user.

I took that to be the default notification_level for the category, which of course categories don’t have.

Thanks, @Falco!

3 Likes

So … by this approach, that means getting a given user’s /categories.json > notification_level requires this update to the client object?

client.api_username = @each_users_username

One cannot just do something like so without changing the client.api_username value?:

client.categories(api_username=@users_username)