To use HttpClient, you need System.Net.dll and Net4, but in unity3d you use Net3.5

HttpClient is in

c: \ Program Files \ Reference Assemblies \ Microsoft \ Framework .NETFramework \ v4.6.1 \ System.Net.dll

but it is not suitable for unity.

using System.Net.Http; using (var client = new HttpClient()) {} var content = new FormUrlEncodedContent(pairs); static HttpClient CreateClient(string accessToken = "") { var client = new HttpClient(); if (!string.IsNullOrWhiteSpace(accessToken)) { client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken); } return client; } 

Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The module cannot be loaded.

at (wrapper managed-to-native) System.Reflection.Assembly: GetTypes (bool)

at System.Reflection.Assembly.GetTypes () [0x00000] in: 0

at Mono.CSharp.RootNamespace.ComputeNamespaces (System.Reflection.Assembly assembly, System.Type extensionType) [0x00000] in: 0

at Mono.CSharp.RootNamespace.ComputeNamespace (Mono.CSharp.CompilerContext ctx, System.Type extensionType) [0x00000] in: 0

at Mono.CSharp.GlobalRootNamespace.ComputeNamespaces (Mono.CSharp.CompilerContext ctx) [0x00000] in: 0

at Mono.CSharp.Driver.LoadReferences () [0x00000] in: 0

at Mono.CSharp.Driver.Compile () [0x00000] in: 0

at Mono.CSharp.Driver.Main (System.String [] args) [0x00000] in

    1 answer 1

    If you need to make an HTTP request, and the class itself is unprincipled, then UnityWebRequest or WWW may be suitable .