Just wondering if it’s possible to enable/disable theme components via API. It seems like there was a way to do it, but there is no mention of it in current
Discourse API Documentation. The clue of such possibility was given by ChatGPT, and yeah, I certainly know this is far from a reliable source of information. I just wonder if this is achievable in any remote way, and the fairy tale ChatGPT told me sounds perfect, but doesn’t work. API returns 404 for admin users’s API credentials.
Asking ChatGPT to refer to the source of it's information on this request
ChatGPT apologizes for mistake...
My guess is ChatGPT just made it all up.
So as you can see, we aren’t all out of a job yet.
There’s no concept of “enabling” or “disabling” a Theme Component, you simply add or remove it from a parent theme. EDIT: incorrect, see @Canapin’s post below!
made it all up. got the wrong end point and body.
Using the browsers network tab, I can see that adding a Theme Component to a parent theme called a
(id of component)
With payload something like:
I didn’t make that up, I just looked at the Network tab on my browser
You are welcome
Sounds like it.
But doesn’t seem to be accessible via external API, though…
Thank you anyway
That’s from a browser, it must be. Make sure your key has the correct authority (single user, global scope).
The concept exists and the buttons are called “Enable” and “Disable” in Discourse’s interface
And it can be done through the API, of course:
Sorry for the long wait. Busy day
So, you can indeed enable or disable a theme or a component with a simple API request.
You’ll have to create an API key with the right credentials and assign an admin user to it.
in your Discourse: admin panel → API → + New API Key
in the script you’ll use, as mentioned, do a PUT request on https://yourdiscourse.com/admin/themes/[id_theme] with the proper headers (see the authentication part on https://docs.discourse.org/) and a JSON body …
I’m talking about both themes AND components in my post but apparently it’s a bit different for themes, so I should fix my solution.
Oh! My bad! Well done!
Those buttons are too far down
But ChatGPT still got it wrong
Amended my post accordingly.
@kinetiksoft so sorry, see above, possible but not how ChatGPT was telling you.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.