jjyao
6월 16, 2023, 10:34오후
1
각 관리자 리포트에 대해 데이터를 가져오기 위한 .json API가 있다는 것을 알고 있습니다. 제가 관심 있는 리포트는 topics_with_no_response이며, 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를 통해 카테고리로 필터링하는 데 성공했습니다. 그러나 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로 JSON 엔드포인트로 전환하면 데이터가 반환되지 않습니다.
이 두 엔드포인트를 쿼리할 때 다른 구문을 사용해야 하나요?
RGJ
(Richard - Communiteq)
6월 16, 2023, 10:42오후
2
어떤 이상한 이유로 GET 대신 POST를 사용해야 합니다.
jjyao
6월 17, 2023, 3:56오전
3
@RGJ 님, 안녕하세요!
POST 요청의 예를 하나 주실 수 있을까요? 본문(body)에는 무엇을 넣어야 하나요? 같은 URL로 GET을 POST로만 변경해 보았지만, 작동하지 않는 것 같습니다.
RGJ
(Richard - Communiteq)
6월 17, 2023, 8:05오전
4
물론 쿼리 매개변수(즉, ? 이후의 모든 내용)를 POST 데이터로 전달해야 합니다.
또한 Run Data Explorer queries with the Discourse API 를 참고하세요.
jjyao
6월 18, 2023, 4:27오전
5
POST로 전환하고 모든 쿼리 매개변수를 POST 데이터로 전달했을 때 “Page Not Found” 오류가 발생했습니다. 하지만 POST를 사용하여 데이터 탐색기 쿼리를 실행하는 것은 가능했습니다. 혹시 어떤 아이디어가 있으신가요? 감사합니다!
simon
6월 18, 2023, 4:57오전
6
Discourse API 역공학 을 참고해 보세요. 이 접근 방식을 ‘응답 없는 토픽’ 보고서에 적용해 보았더니, 다음과 유사한 GET 요청이 수행되는 것을 확인했습니다:
http://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
브라우저 인스펙터의 네트워크 탭에서 인코딩된 쿼리 파라미터를 가져올 수 있습니다. 해당 URL을 사용하면 다음과 같은 작업을 수행할 수 있습니다:
curl -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" \
-H "Api-Key: $api_key" \
-H "Api-Username: system"
api_key를 ‘모든 사용자’ 글로벌 API 키로 설정해야 합니다. 보고서에 사용할 수 있는 특정 스코프가 있다고 생각되지 않습니다.
URL에 json 확장자를 추가해야 함에 유의하세요 (http://localhost:4200/admin/reports/bulk.json).