以下のようにcommentJsonで提議したデータをJsonにして、HTTP通信でサーバーにPOSTしているのですが、「Unable to complete SSL connection」のようなSSLのエラーが帰ってきてしまいます。
httpsで通信してSSLのエラーが出るのでしたらわかるのですが、なぜhttpでsslのエラーが表示されてしまうのでしょうか・・
(ちなみにjQueryのAjax通信でテストしたところちゃんとhttp://aaa.net/post_commentにPOSTできておりました)
commentJson.cs
Jsonのデータを定義しています
using UnityEngine; [System.Serializable] public class Comment { [SerializeField] public int id = 0; [SerializeField] public string content = string.Empty; }
POST実行
Comment c = new Comment(); c.id = 1; c.content = "hoge"; StartCoroutine(httpsScript.postComment(c, addCommentComp));
###POSTのコード
string postCommentUrl = "http://aaa.net/post_comment"; public IEnumerator post(Comment comment, onComplete callback) { string json = JsonUtility.ToJson(comment); byte[] data = Encoding.UTF8.GetBytes(json); UnityWebRequest request = new UnityWebRequest(postCommentUrl, "POST"); request.method = UnityWebRequest.kHttpVerbPOST; Debug.Log(json); request.uploadHandler = (UploadHandler)new UploadHandlerRaw(data); request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); yield return request.SendWebRequest(); if (request.isNetworkError) { Debug.Log(request.error); } else { callback( comment ); } }
あなたの回答
tips
プレビュー