my unity webGL Game doesn't seems sending post request to the server when after build the game, but its working fine in the editor. Is there anything to do additionally than this?
IEnumerator PostRequestY(string url, string jsonToAPI)
{
Debug.Log("--------------Game Data Sending --------------");
var uwr = new UnityWebRequest(url, "POST");
jsonToAPI = jsonToAPI.Replace("'", "\"");
//Debug.Log(jsonToAPI);
byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes(jsonToAPI);
uwr.uploadHandler = (UploadHandler)new UploadHandlerRaw(jsonToSend);
uwr.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
uwr.SetRequestHeader("Content-Type", CONTENT_TYPE);
uwr.SetRequestHeader("x-api-key", X_API_KEY);
//Send the request then wait here until it returns
yield return uwr.SendWebRequest();
if (uwr.isNetworkError)
{
Debug.Log("Error While Sending Game Data: " + uwr.error);
Debug.Log("URL ::: " + url);
messageText.text = uwr.error;
}
else
{
//Debug.Log("Game Data Received: " + uwr.downloadHandler.text);
string recievedMessage = uwr.downloadHandler.text;
//Debug.Log("Respond for Game Data " + recievedMessage);
messageText.text = uwr.downloadHandler.text +" & "+ accessToken;
}
}
This message appears when the game is played in the editor...
This message appears when the game is played after the build...
Why this is happens? Any suggestions would be highly appreciated... Thanks