Hello, We have installed the “Solved” plugin and we are creating Categories programmatically using python script, we want to set this Category setting fields as “True” . While running the script, it says that updated successfully but when we check this category settings field - it is not set to “True” and it is still in “False”. how to debug & fix this issue.
AI-generated summary
The discussion is about enabling the “Solved” field programmatically for each category using a Python script. Steve_John is having trouble setting the category setting field to “True” despite the script reporting a successful update. thoka suggests referencing the Reverse Engineer the Discourse API guide. MihirR provides a potential solution by modifying the endpoint and script, and shares an example Python code snippet that uses the requests.put method to update the category settings. Steve_John confirms that MihirR’s suggestion helped resolve the issue, and also thanks thoka for pointing out the approach. MihirR is glad the solution was helpful.
I always follow Reverse engineer the Discourse API for such questions.
From what I know, if you are building categories with a script, I assume you are using JSON to add the categories. You would have to make some changes to the endpoint and the script. You can also refer to this documentation: Discourse Categories API.
However, Discourse is a powerful tool. You can check out this guide: Reverse Engineering the Discourse API. Since Discourse is backed by a complete JSON API, you can reverse engineer it, make the necessary alterations, and get it to work as needed.
A quick hint:
- Change the desired “Solved” setting manually in the UI.
- Inspect the network requests made by the browser to identify the exact API endpoint, request method (e.g.,
PUT), and payload.
In python script it would look something like this:
payload = {
"enable_solved": True # Adjust this
}
response = requests.put(url, headers=headers, json=payload)
if response.status_code == 200:
print("Category updated")
else:
print(f"Failed: {response.status_code} - {response.text}")
update_category_settings(category_id=123)
PS: I’m not entirely sure about this, but I recently built some scripts, so this response is based on the things I have come across so far. ![]()
Thank You Mihir, it did help to resolve this issue. Appreciate your input and suggestions.
Thank you Thomas for pointing out to this approach.
I’m glad it helped ![]()
