did I HAVE to include the hidden inputs in the postRequest dictionary?
No, you do not have to include the hidden inputs. There is no law, treaty, or standard that requires you to include any particular input elements.
On the other hand, if you fail to include them, then you are doing something different than a browser would do, and the website might take notice of that.
Can you submit a POST request if you omit elements with a type attribute value of "hidden"?
Yes, you can. You can also omit elements with a type of text
or button
. How the website responds is entirely up to it.
What's the purpose of websites even having hidden inputs if their values are set to EMPTY string,
The purposes of the website developer is really up to them. You might ask the developers of the website that you are trying to submit to.
One possible purpose is to identify which form is doing the submission.
Are these extra security measures for the website?
Again, ask the owners of the website. It might be security, it might be session management, or it might carry your preferences.
..and IF SO, how can I programmatically send POST requests, accounting for the changing element values?
Fetch the page that contains the form, parse that page, and submit the form with the indicated form variables.