[Question] Webclient add Auth & Params

Skythrust

Member
Jul 9, 2019
132
7
Hi there,

Does anyone know how I can add parameters like Bearer Authentication + Token and header parameters into Webclient (Newtonsoft JSON)?

  • Authorization; Bearer + Token
  • AddHeader; Content-type - application/x-www-form-urlencoded
  • AddParameter; username - administrator
  • AddParameter; password - Password
  • AddParameter; grant_type - password

C#:
using (var webClient = new WebClient())
{
    string json = webClient.DownloadString(new Uri("http://192.168.2.104:8081/inlist/inlistallquery"));
    var Personal = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ObjectAquarium>>(json);

    foreach (var pv in Personal)
    {
        string Fullname = pv.Name;
        FName = Fullname;
    }             
}

Thanks in advance!
Post automatically merged:

Closed.
 
Last edited:

Users who are viewing this thread

Top