Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Newtonsoft.Json;
- using System.Net;
- using System.IO;
- namespace WindowsFormsApp2
- {
- public partial class Form1 : Form
- {
- public string GetRequest(string url)
- {
- HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest;
- string result = null;
- using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
- {
- StreamReader reader = new StreamReader(resp.GetResponseStream());
- result = reader.ReadToEnd();
- }
- return result;
- }
- public Form1()
- {
- InitializeComponent();
- }
- private void BtnGET_Click(object sender, EventArgs e)
- {
- string URL = "http://127.0.0.1:25555/api/ets2/telemetry";
- textBox1.Text = (GetRequest(URL));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment