Trying to make a JSON POST request using HttpURLConnection, the code that's constructing the JSONObject and writing it to the output stream is here:
            Iterator dataload = data.entrySet().iterator();
            JSONObject sendData = new JSONObject();
            while (dataload.hasNext()) {
                thisEntry = (Entry) dataload.next();
                Object key = thisEntry.getKey();
                Object value = thisEntry.getValue();
                sendData.put(key.toString(), value.toString());
            }
            connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8;");
            connection.setUseCaches (false);
            OutputStreamWriter wr = new OutputStreamWriter(connection.getOutputStream());
            wr.write(sendData.toString());
            wr.flush();
            wr.close();
This shows up in wireshark like this:
https://i.stack.imgur.com/R0tOr.png (can't post images, not enough reputation)
As you can see, the content is being put in the "Line-based text data" field, and not the JSON field, which is present but empty.
Can anyone tell me why this is happening?
