MCPcopy
hub / github.com/microsoft/agent-lightning / _request_json

Method _request_json

agentlightning/client.py:181–196  ·  view source on GitHub ↗

Perform a blocking ``GET`` request and parse the JSON payload. Args: url: Fully qualified URL to query. Returns: Parsed JSON body as a dictionary if the request succeeds; otherwise ``None``.

(self, url: str)

Source from the content-addressed store, hash-verified

179 return await self._post_json_async(url, payload)
180
181 def _request_json(self, url: str) -> Optional[Dict[str, Any]]:
182 """Perform a blocking ``GET`` request and parse the JSON payload.
183
184 Args:
185 url: Fully qualified URL to query.
186
187 Returns:
188 Parsed JSON body as a dictionary if the request succeeds; otherwise ``None``.
189 """
190 try:
191 response = requests.get(url, timeout=self.timeout, headers=self._default_headers)
192 response.raise_for_status()
193 return response.json()
194 except requests.exceptions.RequestException as e:
195 logger.debug(f"Sync GET request failed for {url}: {e}")
196 return None
197
198 def _post_json(self, url: str, payload: Dict[str, Any]) -> Optional[Dict[str, Any]]:
199 """Perform a blocking ``POST`` request with a JSON payload.

Calls 3

raise_for_statusMethod · 0.80
jsonMethod · 0.80
getMethod · 0.45