Advertisement
killerbrenden

VSC

Dec 6th, 2020 (edited)
666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2. using System.Net.Http;
  3. using System.Windows.Forms;
  4.  
  5. namespace CommandAPI
  6. {
  7.     public partial class CommandScreen : Form
  8.     {
  9.         Uri uri = new Uri("https://commandapi.glitch.me/");
  10.         HttpClient client = new HttpClient();
  11.  
  12.         public CommandScreen()
  13.         {
  14.             InitializeComponent();
  15.             client.BaseAddress = uri;
  16.         }
  17.  
  18.         private async void sendButton_Click(object sender, EventArgs e)
  19.         {
  20.             var cmdBox = commandBox;
  21.  
  22.             if (cmdBox.TextLength <= 3)
  23.             {
  24.                 cmdBox.Text = "Enter a valid command";
  25.                 return;
  26.             }
  27.  
  28.             var newTxt = cmdBox.Text.Replace(" ", "_");
  29.  
  30.             var response = await client.GetAsync("getCommands"); // Even if I change the Uri to https://commandapi.glitch.me/getCommands
  31.             Console.WriteLine(response.StatusCode); // Forbidden
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement