MCPcopy Create free account
hub / github.com/canopy-network/canopy / post_raw_json

Function post_raw_json

plugin/python/tutorial/rpc_test.py:68–82  ·  view source on GitHub ↗

HTTP POST helper that sends JSON and returns response body.

(url: str, json_body: str)

Source from the content-addressed store, hash-verified

66
67
68def post_raw_json(url: str, json_body: str) -> str:
69 """HTTP POST helper that sends JSON and returns response body."""
70 req = urllib.request.Request(
71 url,
72 data=json_body.encode('utf-8'),
73 headers={'Content-Type': 'application/json'},
74 method='POST'
75 )
76
77 try:
78 with urllib.request.urlopen(req, timeout=30) as response:
79 return response.read().decode('utf-8')
80 except urllib.error.HTTPError as e:
81 error_body = e.read().decode('utf-8') if e.fp else str(e)
82 raise Exception(f"HTTP {e.code}: {error_body}")
83
84
85def keystore_new_key(rpc_url: str, nickname: str, password: str) -> str:

Callers 7

keystore_new_keyFunction · 0.85
keystore_get_keyFunction · 0.85
get_heightFunction · 0.85
get_account_balanceFunction · 0.85
wait_for_tx_inclusionFunction · 0.85
check_tx_not_failedFunction · 0.85
build_sign_and_send_txFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected