Raritan / Server Technology Xerus™ PDU JSON-RPC API: Curl JSON-RPC Example

Raritan / Server Technology Xerus™ PDU JSON-RPC API

Curl JSON-RPC Example

# Mechanism

Curl is a cross-platform command line tool for getting or sending files using URL syntax. The tool can be used for sending out HTTP POST requests to invoke JSON-RPC methods on a Raritan device. The response document is printed on the standard output of Curl. This is a direct way to check out particular objects and their methods.

Authentication credentials must be provided using options of curl or as part of the URL.

In case HTTPS is used as protocol and the certificate installed on the device cannot be validated curl must be instructed to allow insecure connections using the '-k' option.

In order to direct the request to the desired object implementing a particular interface a well-known resource identfier must be used as part of the URL. All well know URIs are defined in Well-Known Resource IDs.

# Examples

Note: The output of the examples below has been formatted for readability. JSON objects can be pretty-printed by filtering them through tools like `indent` or `python -mjson.tool`.

## Getting device information:

Code:

curl -skd '{ "jsonrpc": "2.0", "method": "getMetaData", "id": 42 }' \
https://admin:raritan@my-py.example.com/model/pdu/0

Result:

{
"jsonrpc": "2.0",
"result": {
"_ret_": {
"ctrlBoardSerial": "PKI9050003",
"fwRevision": "3.0.2.5-41550",
"hasLatchingOutletRelays": false,
"hasMeteredOutlets": false,
"hasSwitchableOutlets": true,
"hwRevision": "0x64",
"isInlineMeter": false,
"macAddress": "00:0d:5d:07:87:5c",
"nameplate": {
"imageFileURL": "",
"manufacturer": "Raritan",
"model": "PX2-2630U-A1",
"partNumber": "",
"rating": {
"current": "24A",
"frequency": "50/60Hz",
"power": "15.0-17.3kVA",
"voltage": "360-415V"
},
"serialNumber": "PKE0954001"
}
}
},
"id": 42,
}

## Switching the first outlet:

Code:

curl -skd '{ "jsonrpc": "2.0", "method": "setPowerState", "params": { "pstate": 1 }, "id": 23 }' \
https://admin:raritan@192.168.7.67/model/pdu/0/outlet/0

Result:

{
"jsonrpc": "2.0",
"result": {
"_ret_": 0
},
"id": 23
}