Don't worry, I had to play around with HTTPRequest for a while to get it to send JSON. Maybe it's not the best way, but it's what works for me.
The request arguments for me are:
url: Just the URL as normal
custom_headers: ["Content-Type: application/x-www-form-urlencoded"]
sslvalidatedomain: false
method: HTTPClient.METHOD_POST
Then for request_data:
Start with a normal dictionary for your key/value pairs.
var data_dict = {"request":"post", "waiting for":"godot" }
Convert that to JSON.
var data_json = to_json(data_dict)
Make the JSON string the value of a key.
data_json = "data=" + data_json
Send the request
HTTPRequest_node.request(
"http://example.com/page.php",
["Content-Type: application/x-www-form-urlencoded"],
false,
HTTPClient.METHOD_POST,
'data={"request":"post", "waiting for":"godot"}'
)
To get the data with PHP:
Get the value of the "data" key (which is the JSON string) and convert it to an associative array.
$request_json = $_POST['data'];
$request_array = json_decode($request_json, true);
Now you should be able to access the values. For example, you could iterate over the array.
for($request_array as $key => $value){
some_method($key);
some_method($value);
}