Search code examples
c#.netdnxdotnet-cli

Using HttpClient with .NET Core Console application


I am trying to access a REST service using the HttpClient in the Microsoft.AspNet.WebApi.Client package

But when i try to build my application i get the following error

Project ProjectTest (.NETCoreApp,Version=v1.0) will be compiled because inputs were modified

Compiling ProjectTest for .NETCoreApp,Version=v1.0
   /.../code/.../src/ProjectTest/project.json(11,46): error NU1002: 
   The dependency Microsoft.AspNet.WebApi.Client 5.2.3 
   does not support framework .NETCoreApp,Version=v1.0.

My project.json contains the following

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },
  "dependencies": {
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0-rc2-3002702"
    },
    "Microsoft.AspNet.WebApi.Client": "5.2.3"

  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports":"dnxcore50"

    }
  }
}

Solution

  • You are referencing the ASP.NET version of HttpClient. There exist one in System.Net.Http.HttpClient as well, maybe you have better luck with that one.