次の Python コードを使用して、任意の REST API リソースからデータを取得します。
GET の例:
>>> request = urllib2.Request("https://zfssa:215/api/network/v1/routes") >>> response = opener.open(request) >>> response.getcode() 200 >>> body = json.loads(response.read()) >>> print json.dumps(body, sort_keys=True, indent=4) { "routes": [ { "destination": "0.0.0.0", "family": "IPv4", "gateway": "10.80.231.1", "href": "/api/network/v1/routes/ixgbe0,0.0.0.0,10.80.231.1", "interface": "ixgbe0", "mask": 0, "type": "static" } ] }