Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using RestSharp;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- var client = new RestClient("http://172.18.68.249/api");
- var request = new RestRequest("/login", Method.POST);
- request.AddHeader("Content-Type", "application/json");
- request.RequestFormat = DataFormat.Json;
- request.AddJsonBody(new { UserName = "Administrator", Password = "Welcome01_", Domain = "Test-domain" });
- IRestResponse response = client.Execute(request);
- Console.WriteLine((int)response.StatusCode);
- var request_list = new RestRequest("/tasks", Method.GET);
- request_list.RequestFormat = DataFormat.Json;
- request_list.AddCookie(".AspNetCore.Cookie", response.Cookies[0].Value);
- IRestResponse response1 = client.Execute(request_list);
- Console.WriteLine((int)response1.StatusCode);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement