thommy1972de

Untitled

May 27th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using Newtonsoft.Json;
  11. using System.Net;
  12. using System.IO;
  13.  
  14. namespace WindowsFormsApp2
  15. {
  16.    
  17.  
  18.     public partial class Form1 : Form
  19.     {
  20.         public string GetRequest(string url)
  21.         {
  22.             HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest;
  23.             string result = null;
  24.             using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
  25.             {
  26.                 StreamReader reader = new StreamReader(resp.GetResponseStream());
  27.                 result = reader.ReadToEnd();
  28.             }
  29.             return result;
  30.         }
  31.  
  32.         public Form1()
  33.         {
  34.             InitializeComponent();
  35.         }
  36.  
  37.         private void BtnGET_Click(object sender, EventArgs e)
  38.         {
  39.             string URL = "http://127.0.0.1:25555/api/ets2/telemetry";
  40.             textBox1.Text = (GetRequest(URL));
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment