Quantcast
Channel: Web API
Viewing all articles
Browse latest Browse all 4850

Security to WebAPI

$
0
0

I just wrote a simple webapi as a test.

 

http://[MachineName]/MyAPI/api/values

 

That works.

 

Now I want to consume that in a console app which is on the same machine.

 

  var client = new WebClient();

  string content = client.DownloadString("http://[MachineName]/MyAPI/api/values");

  Console.WriteLine(content);

  Console.Read();

 

But I get this error:

The remote server returned an error: (401) Unauthorized.

 

Somewhere I should set the security and I am missing that I think.


Viewing all articles
Browse latest Browse all 4850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>