public void Run() { IWebProxy defaultWebProxy = WebRequest.DefaultWebProxy; defaultWebProxy.Credentials = CredentialCache.DefaultCredentials; string content = string.Empty; string boredUrl = $"https://www.boredapi.com/api/activity"; using (var wc = new WebClient() { Proxy = defaultWebProxy }) { content = wc.DownloadString(boredUrl); } BoredModel bored = JsonSerializer.Deserialize <BoredModel>(content); Console.WriteLine(); Console.WriteLine(@$ "Activity -- {bored.Activity}"); Console.WriteLine(@$ "Type -- {bored.Type}"); Console.WriteLine(); }
public static bool Save(BoredModel model) { var client = new RestClient(BaseUrl); var request = new RestRequest("save/{ver}", Method.POST); request.AddUrlSegment("ver", Ver); request.AddObject(model); IRestResponse response = client.Execute(request); return(response.StatusCode == System.Net.HttpStatusCode.OK); }