API for Admin Report Data

AI-generated summary

API for Admin Report Data Discussion Summary

The discussion revolves around accessing admin report data from an HTTP API. codetricity wanted to access reports like /admin/reports/posts.json, /admin/reports/staff_logins.json, and /admin/reports/user_notes.json using a GET request with an admin account’s API key and username. However, they were receiving a 404 error.

Falco requested the cURL script used by codetricity, which was:

curl --request GET \
  --url https://community.domain.com/admin/reports/staff_logins.json \
  --header '"Api-Key": "stringForAPIKey"' \
  --header '"Api-Username": "stringForUsername"' \
  --header '"Content-Type": "applic ation/json"'

Falco then provided a working cURL script:

curl https://meta.discourse.org/admin/reports/staff_logins.json \
  -H 'Api-Key: asdasdasdasd' \
  -H 'Api-Username: Falco'

This solution worked for codetricity, resolving their issues with accessing the admin report data, including the user notes report. The problem was attributed to the use of Insomnia, a tool codetricity was unfamiliar with.

I want to access the admin report data from an HTTP API.

This post seems to indicate that something like this will work:
/admin/reports/posts.json

I am getting an 404 error now.

All the URLs like this, do not seem to work. /admin/reports/staff_logins.json

I can run the API commands from the Discourse API Documentation fine.

My main objective is to get this report:

/admin/reports/user_notes.json

I’m using GET with the Api-Key and Api_Username of an admin account.

Can your share a cURL of the request you are currently issuing ?

Thank you for your help. Here is the curl script I am using

curl --request GET \
  --url https://community.domain.com/admin/reports/staff_logins.json \
  --header '"Api-Key": "stringForAPIKey"' \
  --header '"Api-Username": "stringForUsername"' \
  --header '"Content-Type": "application/json"'

I am getting a 404 error

Can you send me a curl script that works on your system?

I am using Discourse 2.9.0.beta10

The user is an admin.
The API key works for other API commands listed on the Discourse API Documentation site.

Thanks again.

I just did a test on Meta with

curl https://meta.discourse.org/admin/reports/staff_logins.json \
  -H 'Api-Key: asdasdasdasd' \
  -H 'Api-Username: Falco'

and it worked just fine for me. Can you try like that?

@Falco Wow. You’re the man. This solved my problems.

The source of my problem was that I am using a tool called Insomnia to test the API and I don’t have much experience with Insomnia.

Thanks for helping me. I was stuck for a week and I am grateful for your assistance. This also solved a different problem I was having with the user_notes reports.