Web Request Gives "uknown Error" After Upgrade Unity To 2018

Hi all,

When my project was on Unity2017.4.21f1, it was working.
After upgrade to 2018.3.11f1 it started to give “Unknown Error”

Here is my code

 WWWForm form = new WWWForm();
        form.AddField("email", email_id);
        form.AddField("password", password);
        UnityWebRequest www2 = UnityWebRequest.Post("https://api.var-port.com/api/v1/login", form);
        www2.chunkedTransfer = true;
        yield return www2.SendWebRequest();
        Debug.Log("Error : " + www2.error);
        Debug.Log("downloadHandler Text : " + www2.downloadHandler.text);
        Debug.Log("responseCode : " + www2.responseCode);
        Debug.Log("isDone : " + www2.isDone);
        Debug.Log("method : " + www2.method);

It gives:
Error : Unknown Error
downloadHandler Text :
responseCode : 0
isDone : True
method : POST

I searched on Google and Unity forms and found some solutions.
I also tried

class AcceptAllCertificatesSignedWithASpecificKeyPublicKey : CertificateHandler
{

    // Encoded RSAPublicKey
    private static string PUB_KEY = "MyLongKEYString";
    protected override bool ValidateCertificate(byte[] certificateData)
    {
        X509Certificate2 certificate = new X509Certificate2(certificateData);
        string pk = certificate.GetPublicKeyString();
        if (pk.ToLower().Equals(PUB_KEY.ToLower()))
            return true;
        return false;
    }
}

and

class NoCheckCertificatePolicy : System.Net.ICertificatePolicy
{
    public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem)
    {
        return true;
    }
}

But nothing changes.
Do you have any solutions for that on server or in Unity?

Thanks

One known possible reason is when server doesn’t support HTTP 100-Continue, you can disable that by setting useHttpContinue to false.
As for certificate handling, the second one is for .NET APIs, not UnityWebRequest, and the first one has to be actually attached to UnityWebRequest. If possibl, try doing a HTTP request instead of HTTPS, that way you will know if request fails due to certificate issues and not something else.

Thanks but that is not working.
Any changes between Unity2017 and Unity2018?
If I try same code with Unity2017 it works but not with Unity2018.

What is not working? I gave you two options to try.

Sorry,

Set useHttpContinue to false is not working.
Trying HTTP is not working.

Both of them give same “Unknown Error”

Thanks

That’s interesting. What platform is this on?

I am working on Mac.
Platform is Android.
I am testing and taking that error on Editor.

Error on Mac Editor? Great, it means you can install something like Charles proxy and inspect the network traffic. Seeng raw request should reveal the reason.
Just make sure you use HTTP, rather than HTTPS, to remove the extra layer of complexity.