That's a URL, not a request. And even the URL is not correct. There is no device or group.
Please add time request to this code. That would be really helpful
private void test()
{
string url = "http://track.gatsan.com:80/api/positions";
var pairs = new List<KeyValuePair<string, string>> { };
var byteArray = Encoding.ASCII.GetBytes("admin" + ":" + "admin");
var client = new HttpClient();
client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json");
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var content = new FormUrlEncodedContent(pairs);
var response = client.GetAsync(url).Result;
HttpStatusCode statusCode = response.StatusCode;
switch (statusCode)
{
case HttpStatusCode.OK:
{
response.EnsureSuccessStatusCode();
string res = response.Content.ReadAsStringAsync().Result;
if (response.IsSuccessStatusCode)
{
JArray rows = JArray.Parse(res);
if (rows.HasValues)
{
foreach (JToken row in rows)
{
MessageBox.Show(row.ToString());
}
}
}
}
break;
}
}
Please tell me is this a valid http request from getting past positions