Using HTTP with Sony's Audio Control API
Unlike a REST Web API implemented in REST format, you cannot call the Audio Control API by entering the URL on the address bar of your internet browser. However, you can use a tool such as cURL or Postman to easily test sending commands to your device.
This example explains how to access the Audio Control API using cURL. The data parameters in the HTTP call are formatted as JSON data and are included in request body of an HTTP POST request.
Before you begin
To communicate with a physical product, it must be accessible from your device and the product must be configured properly on the network, according to the product’s user manual.
Note! To find the {ipaddress} and {port} number see X_ScalarWebAPI_BaseURL in Discovery Process, for example, for Home Audio products the port is usually 10000 and for Personal Audio products, 54480. The {ipaddress} is the IP address of the audio product.
Step 1: Requirements
To follow the HTTP API example, you must have cURL installed on your computer, and you need to beable to connect to your audio product via the network. For more information and instructions, see http://curl.haxx.se/ and http://en.wikipedia.org/wiki/CURL.
In these examples, we use the following cURL parameters:
Parameter | Description |
---|---|
Parameter -i | Description Include the header information with the Response. |
Parameter -d DATA | Description Specify the data to set in the Response Body |
Step 2: Get system information from your device
To get the system information from the audio product, call the system/getSystemInformation, version 1.4. This JSON-RPC command is very simple and does not have any extra parameters. The resulting cURL command is:
$> curl -i -d '{"method": "getSystemInformation","id": 65,"params": [],"version": "1.4"}' http://192.168.0.123:10000/sony/system
If the function is successful, you will get a response similar to the following:
HTTP/1.1 200 OK
Connection: close
Content-Length: 119
Content-Type: application/json
Body: {"result": [{"esn": "SONY-16BDP50012O1TRFL280BFAVWE","wirelessMacAddr": "ec:0e:c4:18:49:07","deviceID": "B0:00:03:08:9E:98","version": "M30.R.0095","lastPowerOnTime": "2016-07-28T10:00:00Z","initialPowerOnTime": "2016-05-10T13:00:00Z","macAddr": "fc:f1:52:7b:99:df"}],"id": 65}