Real Time Automation, Inc.
51
1-800-249-1612
Writing Data to the Gateway
All data writes to the 460WI use the HTTP POST method. There are two primary ways through which you
can post data to the 460WI. The first is using the
application
/
x-www-form-urlencoded
standard post
format. The second method is to use the
multipart-form data
post format to post JSON or XML to the
460WI and is most easily thought of as simply uploading an XML or JSON file to the 460WI. A simple way
to think of these is that the
multipart-form data
post method is akin to uploading an XML or JSON file to
the 460WI, and the
application
/
x-www-form-urlencoded
post
method like submitting values from a
form to a web page.
Which method to use?
Either method may be used to achieve the same results, so which method chosen depends upon several
factors, not the least of which is simply whichever method is more convenient for you. A possible
example where the
multipart-form data
post would be more convenient is in a recipe manager or
similar implementation, where pre-defined XML or JSON files containing static data are written to the
460WI. It may also be the easier choice for IT backend integration where symmetry in communication
models is desirable and JSON and XML parsing and generation is common practice.
The
application
/
x-www-form-urlencoded
post
method may be more useful in situations where one or a
small number of data points
are frequently written to and generating XML or JSON is inconvenient.
Aside from the encoding method itself, the primary functional difference between the two methods is
that the
multipart-form data
method may be used to write all the devices
and data points configured in
the 460WI with a single HTTP transaction. The
application
/
x-www-form-urlencoded
post
method, on
the other hand, can only write to a single device per HTTP transaction and thus would require a separate
POST operation for each device that is to be written to.
The multipart/form data Method
The multipart/form data post is the standard method for uploading files to web servers. This method
encodes the contents of a file within the POST message body. Using this method, you will upload your
data encoded in one of the supported formats (XML, JSON) and then the 460WI will decode the format,
validate the contents and then perform the write operations. Note that your data need not be a “file” in
the sense of a file on a computer, though of course it could be. Rather, t
he “file” could just as well be
generated on-the-fly by an application, scripting language or library.
The exact details of the operation of the multipart/form data post method has more complexity than is
suitable for discussing here. These details will generally be handled by your application, scripting
language or library. There are many good resources available online describing the operations and
formatting involved beginning with the current IETF specification in
As a user of the 460WI, the only detail you likely need to be concerned with is the
HTTP name
attribute
associated with the data. This depends on the encoding you are using. If you are using XML to encode