UnityWebRequest.Get error

Im trying to use this code Unity - Scripting API: Networking.UnityWebRequest.Get with this url: www.kinówki.pl (which is valid in browser) and I get error:
www.kinówki.pl: Error: Cannot resolve destination host
I tryed https://www.kinówki.pl too and get this error:
www.xn–kinwki-dxa.pl: Error: Unknown Error

How do I get such a domain?

Could you paste the actual code that you use?

using UnityEngine;
using UnityEngine.Networking;
using System.Collections;

public class ButtonsHandler : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        StartCoroutine(GetRequest("https://www.kinówki.pl"));
        StartCoroutine(GetRequest("https://www.xn--kinwki-dxa.pl"));
    }

    // Update is called once per frame
    void Update()
    {
     
    }

    IEnumerator GetRequest(string uri)
    {
        using (UnityWebRequest webRequest = UnityWebRequest.Get(uri))
        {
            // Request and wait for the desired page.
            yield return webRequest.SendWebRequest();

            string[] pages = uri.Split('/');
            int page = pages.Length - 1;

            if (webRequest.isNetworkError)
            {
                Debug.Log(pages[page] + ": Error: " + webRequest.error);
            }
            else
            {
                Debug.Log(pages[page] + ":\nReceived: " + webRequest.downloadHandler.text);
            }
        }
    }
}

The code looks good. It seems the second URI redirects to first, try debugging the request using tools like Fiddler or Charles.
I can only guess that the special character causes the problem due to encoding or something like that.

When I add code like this:

            var request = (HttpWebRequest)WebRequest.Create("https://www.xn--kinwki-dxa.pl");
            var response = (HttpWebResponse)request.GetResponse();
            string responseString;
            using (var stream = response.GetResponseStream())
            {
                using (var reader = new StreamReader(stream))
                {
                    responseString = reader.ReadToEnd();
                }
            }

I get more specific error:
TlsException: Handshake failed - error code: UNITYTLS_INTERNAL_ERROR, verify result: UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED

Is there any way to get around it (Im not owner of the domain)?

And I found this:
https://issuetracker.unity3d.com/issues/error-of-tlsexception-when-system-dot-net-dot-http-dot-dll-is-used-for-http-in-the-editor
But I dont get the solution.

UnityWebRequest has ability to attach SertificateHandler that would trust any website. Such alternative also exists in .NET APIs.
However I’m not sure this will help you. This has to be certificate issue in the first place. Have you tried Fiddler?

Is UnityWebRequest be deprecated? Do you have suggestions for alternatives? Or is there a thread of community about alternatives to UnityWebRequest?

No, UnityWebRequest is not deprecated. Where did you get an idea about it?

Oh okay. I saw that UNet will be deprecated. Will it not affect the UnityWebRequest class?

No, UnityWebRequest and UNet are separate things.

I have the same issue with error log UNITYTLS_X509VERIFY_FLAG_NOT_TRUSTED

  • Charles does not easily want to track SSL website calls from Unity applications due to a certificate error. This is a very common tool to track server calls (though not sure on SSL sites) so unfortunate, but maybe someone has the solution

Edit, found a helpful Unity article to fix: https://support.unity3d.com/hc/en-us/articles/115002917683-Using-Charles-Proxy-with-Unity