public static UnityWebRequest Post(string uri, Dictionary <string, string> formFields) { UnityWebRequest unityWebRequest = new UnityWebRequest(uri, "POST"); byte[] data = UnityWebRequest.SerializeSimpleForm(formFields); unityWebRequest.uploadHandler = new UploadHandlerRaw(data) { contentType = "application/x-www-form-urlencoded" }; unityWebRequest.downloadHandler = new DownloadHandlerBuffer(); return(unityWebRequest); }
private static void SetupPost(UnityWebRequest request, Dictionary <string, string> formFields) { byte[] data = null; if (formFields != null && formFields.Count != 0) { data = UnityWebRequest.SerializeSimpleForm(formFields); } request.uploadHandler = new UploadHandlerRaw(data) { contentType = "application/x-www-form-urlencoded" }; request.downloadHandler = new DownloadHandlerBuffer(); }