frosty
frosty

Reputation: 5370

webclient request via authentication

I'm calling a clients endpoint which "get" a json array. Like so

 var json = new WebClient().DownloadString(url);

They are using authentication and i have the username and password. Is it possible to submit the username and password. Maybe i need to add custom headers? I can't find the exact examples for what i'm after

enter image description here

401 - Unauthorized: Access is denied due to invalid credentials.

Upvotes: 0

Views: 167

Answers (1)

Alexander
Alexander

Reputation: 431

You may try to specify your credentials:

var json = new WebClient { Credentials = new NetworkCredential(username, passwd) }.DownloadString(url);

Upvotes: 1

Related Questions