using System.Net; ... static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // SSL-Validierungsprüfung global für die gesamte Anwendung umgehen. // https://stackoverflow.com/questions/10397736/restsharp-ignore-ssl-errors ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; Application.Run(new Form1()); }
using RestSharp;using RestSharp.Authenticators;using System;using System.Windows.Forms;using Newtonsoft.Json;namespace FE_FirewallInternetConfigurator{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Test_Click(object sender, EventArgs e) { // SSL-Validierungsprüfung wird in der Program.cs umgangen var client = new RestClient(@"https://MEINEFIREWALL:8443/"); string consumerKey = "MEIN KEY"; string consumerSecret = "MEIN SECRET"; client.Authenticator = OAuth1Authenticator.ForRequestToken(consumerKey, consumerSecret); //client.Authenticator = new HttpBasicAuthenticator(@"UserName", @"Passwort"); var request = new RestRequest(@"api/core/firmware/status"); var queryResult = client.ExecuteGetAsync<Object>(request).Result; string json = JsonConvert.SerializeObject(queryResult); //System.IO.File.WriteAllText(@"C:\...\path.json", json); } }}
"Content":"{\"status\":401,\"message\":\"Authentication Failed
client.Authenticator = new HttpBasicAuthenticator(consumerKey, consumerSecret);
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // SSL-Validierungsprüfung global für die gesamte Anwendung umgehen. // https://stackoverflow.com/questions/10397736/restsharp-ignore-ssl-errors ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; Application.Run(new Form1()); }
private void Test_Click(object sender, EventArgs e) { // SSL-Validierungsprüfung wird in der Program.cs umgangen var client = new RestClient(@"https://FirewallNameOderIP:8443/"); string consumerKey = "Mein Key"; string consumerSecret = "Mein Secret"; client.Authenticator = new HttpBasicAuthenticator(consumerKey, consumerSecret); var request = new RestRequest(@"api/core/firmware/status", Method.Get); var queryResult = client.ExecuteGetAsync<Object>(request).Result; string json = JsonConvert.SerializeObject(queryResult); //System.IO.File.WriteAllText(@"C:\...\path.json", json); }