19 lines
667 B
C#
19 lines
667 B
C#
|
|
using System.Net.Http.Json;
|
|
using System.Text;
|
|
|
|
HttpClient client = new HttpClient();
|
|
|
|
HttpRequestMessage requestMessage=new HttpRequestMessage(HttpMethod.Get,"http://localhost:24240/api/route/jsonEndpoint");
|
|
requestMessage.Headers.Add("Authorization",$"Basic {Convert.ToBase64String(Encoding.UTF8.GetBytes("demi:password123"))}");
|
|
requestMessage.Content = JsonContent.Create(new Obj());
|
|
var resp=await client.SendAsync(requestMessage);
|
|
Console.WriteLine(await resp.Content.ReadAsStringAsync());
|
|
|
|
|
|
public class Obj
|
|
{
|
|
public string Name {get;set;}="Demetria Devonne Lovato";
|
|
|
|
public DateTime Birthday {get;set;}=new DateTime(1992,8,20);
|
|
} |