The discussion revolves around querying the topics_with_no_response.json API with filters. jjyao initially encountered issues when switching from a .json API with filters to the corresponding JSON endpoint. RGJ suggested using a POST request instead of GET, passing the query parameters as the POST data.
However, jjyao still faced issues, and simon proposed an alternative approach. By analyzing the API requests made by Discourse, simon found that the topics_with_no_response report uses a GET request with a different URL structure. He provided an example curl command that successfully retrieves the data.
jjyao confirmed that this approach works. To summarize, the solution involves:
Using a GET request
Passing the query parameters in the URL
Adding the .json extension to the URL
Using a URL structure similar to http://forum.example.com/admin/reports/bulk.json?...
Setting an All Users Global API key in the Api-Key header
This approach allows for successful querying of the topics_with_no_response.json API with filters.
I know that for each admin report, there is a .json API to fetch the data. The report I’m interested in is topics_with_no_response and I was able to filter by category via https://xxx.com/admin/reports/topics_with_no_response?end_date=2023-06-16&filters=%7B%22category%22%3A7%2C%22include_subcategories%22%3Atrue%7D&mode=table&start_date=2023-06-14. However if I switched to the json endpoint via https://xxx.com/admin/reports/topics_with_no_response.json?end_date=2023-06-16&filters=%7B%22category%22%3A7%2C%22include_subcategories%22%3Atrue%7D&mode=table&start_date=2023-06-14, it doesn’t return the data.
Do we have different syntax to query these two endpoints?
Could you give me an example of the POST request? What should be the body? I tried to just change GET to POST with the same URL but it seems doesn’t work.
When I switched to POST and pass all the query parameters as the POST data, I got “Page Not Found”. However I was able to use POST to run data explorer queries. Do you have any ideas? Thanks!
Have a look at Reverse engineer the Discourse API. When I try that approach for the Topics With no Response report, I’m seeing it make GET requests similar to: