I have a json file
{
"SystemId": "VARinicom2",
"SystemName": "EO System",
"SensorType": "Visual",
"Latitude": 1.3391904,
"Longitude": 103.7414429
}
This file is at this URL
https://api.myjson.com/bins/1crza2
If I want to update the Latitude and Longitude every seconds using C#, how can it be done?
I try to do something simple.
public class RunJsonDemo
{
static string url = "https://api.myjson.com/1crza2";
string json = File.ReadAllText(url);
dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
jsonObj["Latitude"] = "new latitude";
}
It is not working, what should I do?
This is what I did so far
public static void HTTP_PuttoURL(string requestUri, string data)
{
try
{
WebRequest req = WebRequest.Create(requestUri);
req.Method = "PUT";
req.Timeout = 10000;
req.ContentType = "application/json";
byte[] sentData = Encoding.UTF8.GetBytes(data);
req.ContentLength = sentData.Length;
using (Stream sendStream = req.GetRequestStream())
{
sendStream.Write(sentData, 0, sentData.Length);
sendStream.Close();
}
}
catch (Exception ex)
{
}
}
THE FILE IN THE URL IS NOT UPDATED