Skip to main content

Writing Data (POST Method)

To store data on the server, you must send an HTTP POST request with URL-encoded form data. The MIO Server accepts parameters like folder name, file name, and message content.


Required Parameters

ParameterDescription
keyPassword defined in config.ini (password=...)
tokenFolder name where the file will be stored
fileFilename to save the data into (within the token folder)
messageContent of the message (plain text or CSV data, etc.)

Optional Parameters

ParameterDescriptionDefault
modeoverwrite or append (controls file write behavior)overwrite

Example cURL Command

curl -d "key=public&token=device01&file=data.txt&message=Hello+world" http://localhost:9123

To append a new line to an existing file:

curl -d "key=public&token=device01&file=data.txt&message=Another+line&mode=append" http://localhost:9123

Error Responses

HTTP CodeMeaning
403Invalid or missing key
413Message too large
400Malformed request
500File write error on disk

File Structure

Files are stored in:

[serverpath]/[token]/[file]

For example:

./db/device01/data.txt

Each token becomes a folder. Files inside will be either created new or appended depending on mode.


📝 Notes

  • Message size must not exceed maxmessage defined in config.ini
  • If the folder or file does not exist, it will be created
  • message should be URL-encoded (e.g., spaces = +)
  • mode=append automatically adds a \n newline after each message (if not present)