Pass multiple arguments from an HTML form using POST to REST API


(This might end up being more of an HTML question since I’m not an expert in web stuff, but here goes…)

I followed the REST API example for LEDs in the docs and I was able blink LEDs from an HTML form. Looking at the code, it seems that only a single value is passed through “args”: “on” or “off”. I’d now like to pass multiple arguments.

I modified the code to have 2 radio buttons (“left” and “right”), a text field (“steps”), and a submit button as follows:

<!DOCTYPE html>

<form action="" method="POST">
<legend>Motor Calibration</legend>
<input type="radio" name="direction" value="left">Turn left
<input type="radio" name="direction" value="right">Turn right
Number of steps:<br>
<input type="text" name="steps">
<input type="submit" value="Do it!">


On the Photon I put a serial print in turn() that simply prints out the String argument. I’m listening to it over serial on a host machine.

What I observe is that only the first argument, “left”/“right” or “steps”, is passed to turn(), but not both. For example: if I check “Turn left” and hit submit, turn() gets “left”. If I enter “123” in the text box and hit submit, turn() gets “123”. But if I do both and then hit submit, turn() gets only “left”.

Is there a way to pass both arguments at once, or do I have to concatenate them into a string on the HTML page? If I need to do the latter, can someone please point me to a tutorial/example ?