Hi, I want to use a GET Request as such to obtain all categories in my Discourse server.
resp = requests.get(base_url + "/categories.json", headers={"Api-Key": clef_api, "Api-Username": "system"}, param={'include_subcategories': 'true'} ,auth=auth)
assert(resp.status_code == 200)
Unfortunally, as they pull the descriptions of the categories, with all the current categories, I receive a 413 HTTP error (Payload Too Large). So, I’d like to be able to opt out of pulling Categories descriptions to pull less data.
Can you help me ? thx
1 Like
pfaffman
(Jay Pfaffman)
June 29, 2022, 8:40am
2
I think you need to use params
and not data
…
GET always has a query string and never has post data (that is why you are getting 413 payload too large, it does not expect any). When querying data from a server without making a change you’ll (almost) always use GET and not POST. So you should use params= instead of data=.
I think the docs for this specific API call are badly phrased (“Request Body schema ” really indicates POST data) so I am moving this to #bug and you don’t need to pay me anything.
import requests
import json
def get_post…
4 Likes
pfaffman
(Jay Pfaffman)
June 29, 2022, 12:41pm
4
Glad that did the trick! I’ve been confused by that myself. Thanks to @RGJ for his lucid explanation.
3 Likes
system
(system)
Closed
July 29, 2022, 12:41pm
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.