Come interrogare l'API topics_with_no_response.json con filtri

So che per ogni report admin, c’è un’API .json per recuperare i dati. Il report che mi interessa è topics_with_no_response e sono riuscito a filtrare per categoria tramite 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. Tuttavia, se passo all’endpoint json tramite 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, non restituisce i dati.

Abbiamo una sintassi diversa per interrogare questi due endpoint?

Devi usare POST invece di GET per qualche strano motivo.

Ciao @RGJ,

Potresti fornirmi un esempio della richiesta POST? Quale dovrebbe essere il corpo? Ho provato a cambiare semplicemente GET in POST con lo stesso URL ma sembra non funzionare.

Ovviamente dovrai passare i parametri della query (cioè tutto ciò che segue il ?) come dati POST.

Vedi anche Run Data Explorer queries with the Discourse API

Quando sono passato a POST e ho passato tutti i parametri di query come dati POST, ho ricevuto "Pagina non trovata". Tuttavia, sono stato in grado di utilizzare POST per eseguire query di esplorazione dati. Hai qualche idea? Grazie!

Dai un’occhiata a Reverse engineer the Discourse API. Quando provo questo approccio per il report “Argomenti senza risposta”, vedo che effettua richieste GET simili a:\n\nhttp://forum.example.com/admin/reports/bulk?reports%5Btopics_with_no_response%5D%5Bfacets%5D%5B%5D=prev_period&reports%5Btopics_with_no_response%5D%5Bstart_date%5D=2022-02-01&reports%5Btopics_with_no_response%5D%5Bend_date%5D=2023-06-17&reports%5Btopics_with_no_response%5D%5Blimit%5D=50\n\nPuoi ottenere i parametri di query codificati dalla scheda Network dell’inspector del tuo browser. Con quell’URL, dovresti essere in grado di fare qualcosa di simile a:\n\n\ncurl -X GET \"http://localhost:4200/admin/reports/bulk.json?reports%5Btopics_with_no_response%5D%5Bfacets%5D%5B%5D=prev_period&reports%5Btopics_with_no_response%5D%5Bstart_date%5D=2022-05-16&reports%5Btopics_with_no_response%5D%5Bend_date%5D=2022-09-10&reports%5Btopics_with_no_response%5D%5Blimit%5D=50\" \\\n-H \"Api-Key: $api_key\" \\\n-H \"Api-Username: system\"\n\n\nDovrai impostare api_key su una chiave API globale per tutti gli utenti - non credo ci sia uno scope specifico che possa essere utilizzato per i report.\n\nNota che devi aggiungere l’estensione json all’URL (http://localhost:4200/admin/reports/bulk.json)

1 Mi Piace

Grazie @simon, funziona!!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.