unitywebrequest-post-url-jsondata
IEnumerator Post(string url, string bodyJsonString) { var request = new UnityWebRequest(url, "POST"); byte[] bodyRaw = Encoding.UTF8.GetBytes(bodyJsonString); request.uploadHandler = (UploadHandler) new UploadHandlerRaw(bodyRaw); request.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); yield return request.Send(); Debug.Log("Status Code: " + request.responseCode); }
Oddly Unity has two different ways? I found that this version they supply works?
https://docs.unity3d.com/ScriptReference/Networking.UnityWebRequest.Post.html
Yes, there are two ways:
UnityWebRequest.Post(url, form);
and
new UnityWebRequest(url, "POST");