MCPcopy
hub / github.com/openai/plugins / request_json

Function request_json

plugins/sentry/skills/sentry/scripts/sentry_api.py:54–78  ·  view source on GitHub ↗
(url, token, retries=1)

Source from the content-addressed store, hash-verified

52
53
54def request_json(url, token, retries=1):
55 req = Request(url)
56 req.add_header("Authorization", f"Bearer {token}")
57 req.add_header("Accept", "application/json")
58
59 attempt = 0
60 while True:
61 try:
62 with urlopen(req) as resp:
63 body = resp.read().decode("utf-8")
64 data = json.loads(body) if body else None
65 return data, resp.headers
66 except HTTPError as err:
67 body = err.read().decode("utf-8", "ignore")
68 if attempt < retries and (err.code >= 500 or err.code == 429):
69 attempt += 1
70 time.sleep(1)
71 continue
72 raise RuntimeError(f"HTTP {err.code} for {url}: {body or 'request failed'}") from err
73 except URLError as err:
74 if attempt < retries:
75 attempt += 1
76 time.sleep(1)
77 continue
78 raise RuntimeError(f"Network error for {url}: {err.reason}") from err
79
80
81def build_url(base_url, path, params=None):

Callers 3

paged_getFunction · 0.70
handle_issue_detailFunction · 0.70
handle_event_detailFunction · 0.70

Calls 1

sleepMethod · 0.80

Tested by

no test coverage detected