The Unity C# code below is sending a username and a new and old password to a server that should be using PUT to update the database. The body in the request is blank on the server. uriBase is the base domain for the endpoint. The only way I can get my data to the server is to use URL parameters like a GET and using reqest.query to get the values but that is not the proper way to do it. Server is running NodeJs and MongoDB. Any ideas why the body would be received as empty? Alternatively, if anyone has any better suggestions without buying a Unity Asset to get the put request to work correctly, that would be appreciated. Thanks guys.
IEnumerator changePasswordCallout() {
string jsonRequest = "{\"username\":\"" + UsernameField.text + "\",\"oldPassword\":\"" + OldPasswordField.text + "\",\"newPassword\":\"" + NewPasswordField.text + "\"}";
byte[] body = System.Text.Encoding.UTF8.GetBytes(jsonRequest);
UnityWebRequest request = UnityWebRequest.Put(uriBase + "/password/change", body);
yield return request.SendWebRequest();
if (request.isNetworkError || request.isHttpError) {
// error code
} else {
// not error code
}
}