UMAX140900RST. Ethernet to CAN Converter. Version 1
Page: 30-41
8
RESTful API Processing
A RESTful API is an architectural style for an application program interface (API) that uses
HTTP requests to access and use data. The Converter
’s HTTP server uses the HTTP protocol
at a predefined set of URLs and treats them as APIs. These URLs represent resources
available at HTTP server
’s web page and have one or more methods that can be performed on
them like GET, POST, PUT.
All HTTP API requests must have the encoding of
application/x-www-form-urlencoded
. Most
APIs require one or more parameters. These parameters are passed as part of the message
and have a rigid structure - parameter ID, followed by an equal sign, and then by the
parameter value (i.e,
EthDeviceIpAddr
=192.168.0.34). Several parameters can be chained
together with the ampersand[&] (i.e.,
EthDeviceIpAddr
=192.168.0.34&
EthDevicePort
=4000).
Blank spaces are not allowed. All parameters relevant to an API could be provided in the body
of the same request.
For example, the following request sets the IP address to 192.168.1.34, port 4000 TCP:
A GET request is used to get a list of resources. If the resource is found on the server, then it
returns HTTP response code 200 (OK)
– along with the response body. The returned data is in
JSON (JavaScript Object Notation) and can be accessed directly.
If the resource is
n’t found on the server, API returns HTTP response code 404 (NOT FOUND).
Similarly, if it is determined that the GET request itself is not correctly formed then the server
will return the HTTP response code 400 (BAD REQUEST).
A PUT request is used to update existing resources.
A POST request is used to upload a firmware.
8.1 Converter Settings
Converter’s connection profile can be changed by posting PUT to
/api/settings
the parameters
listed in Table 5 (all are case sensitive) without limitations on number of parameters.
Table 5. RESTful API Parameters for Converter settings
API Parameter
Configuration Parameter
Range
DevPartNumber
Device Part Number
Read only
DevSerialNumber
Device Serial Number
Read only
DevFirmwareVersion
Device Firmware version
Read only
EthMACAddress
Device MAC Address
Read only
EthDeviceIpAddress
Device IP Address
Any IP address
EthDevicePort
Device Port
Any port value except the
Web Server Port
and the
Discovery Protocol Port
EthDevicePortType
Device Port Type
{UDP, TCP}
EthWebServerPort
Web Server Port
Any port value except the
Device Port
and the
Discovery Protocol Port
EthDeviceSubnetMask
Device Subnet Mask
Any IP address
EthDeviceDefaultGateway
Device Default Gateway
Any IP address
EthAutoConnectToRemote
Auto Connect to Remote
{0-No, 1-Yes}
EthRemoteIpAddress
Remote IP Address
Any IP address
EthRemotePort
Remote Port
Any port value
PUT http://192.168.0.34/api/settings?Eth
DeviceIpAddr
=192.168.1.34&Eth
DevicePort
=4000&Eth
DevicePortType
=TCP