Issue with WWW/UnityWebRequest when sending JSON to server

Hi all, I have a problem when using either WWW/UnityWebRequest to send JSON data to my server.

I have tested my server request API on Postman, and it works. The server sends back text msg (like “Success”). But it doesn’t work on Unity3D. I have tried both WWW and UnityWebRequest to send my JSON data. The code shows below, (I only posted UnityWebRequest one),

btw: the JSON I want to send is {“data”, AnotherJSON}, thus I AddField by AddField(“data”, jsonstr)

 IEnumerator PostData(){
    		User usr = new User();
    		usr.name = "abc";
    		usr.email = "abc@gmail.com";
    		usr.age_range = 23;
    		usr.gender = "male";
    		usr.location = "U.S.";
    		string jsonStr = JsonConvert.SerializeObject(usr);
    
    		WWWForm form = new WWWForm();
    		form.AddField("data", jsonStr);
    		//Dictionary<string, string> headers = form.headers;
    		//headers["Content-Type"] = "application/json";
    		UnityWebRequest uwr = UnityWebRequest.Post(addUerURL, form);
    		uwr.SetRequestHeader("Content-Type", "application/json");
    		yield return uwr.Send();
    
    		string s = uwr.downloadHandler.text;
    		if(uwr.isError){
    			Debug.Log(uwr.error);
    		}else{
    			Debug.Log("Success? " + s);
    		}
}

The User class is just a public class contains basic info using default constructor. The output goes into “No Error” and prints “Sucess? 400 Bad Request” which indicates my request are malformed.

And when I use “WWW www” as sending my request, I got the same, 400 Bad Request.

Anyone can help me out??? A lot thanks in advance.

For those want the answer immediately, I got it works not using Unity’s Networking, but System.Net. Using HttpWebRequest, this link helps alot How to post JSON to server. And you may encounter “417 expectation failed”, in which case you need this.

But I still want to know how Unity3D works. Or maybe it’s because I used UnityEngine.Experiemental.Networking? I am currently using 5.3.5f1, not gonna to update to 5.4.0