Unity returns NULL when I try to send a HTTPS request

I’m struggling to send a HTTPS request on Unity for about 3 days. I did search a lot about it and what I understand is that Mono doesn’t support SSL validation.

There is a solution for this on the internet. Putting this snippet code in above of HTTP request code.

ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;

But, unfortunately, it’s not working.

I’m using the “Http Client” asset: Unity Asset Store - The Best Assets for Game Making

My code:

public string send()
{
    HttpClient httpClient = new HttpClient();
    ServicePointManager.ServerCertificateValidationCallback += (o, certificate, chain, errors) => true;
    httpClient.GetString(new Uri("https://jsonplaceholder.typicode.com/todos/1"), (r) =>
    {
        Debug.Log(r.Data);
    });
}

I would be glad If someone can help me on this. I’ve tried the official HTTP APIs of Unity but the result is same. Please don’t suggest me to upgrade the runtime or Unity version. I’m making a Unity asset for botdelive and it should work on every version of it. By the way, I don’t want to use StartCoroutine/IEnumerator.

**Unity version: 2017.3.1.f1

Runtime version: .NET 3.5

Api Compatibilitiy Level: .NET 2.0 Subset**

no idea how the http client works.
but try r.text or r.data.text
i could tell you how to do it with the built in unity functions if that doesnt work.

if you don’t use IEnumerator it doesn’t wait for the data to be retrieved so it will always return null… because you didn’t wait for the packet to be delivered