I want to store some simple user data to a JSON file on my server so I can use it with my PHP. I know how to create a JSON file thanks to this handy article: How to write a Json file in C#? But in this article they save the file locally but I want it to save it on my external server but don't know how since I never really used JSON before. Can someone tell me if it's possible and so how what kind of method do I need to use? I thought something like this would work, atleast it seemed reasonable to me:
var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://" + ConfigurationManager.AppSettings["jsonuri"] +"/apptest/saleskickerbuffer.txt");
httpWebRequest.ContentType = "application/json";
httpWebRequest.Method = "POST";
using (var sw = new StreamWriter(httpWebRequest.GetRequestStream()))
{
if(reqCat == "bvg")
{
json = "{\"bedrijfsNaam\":\"" + bedrijfsNaam + "\"," +
"\"ContPers\":\"" + ContPers + "\"," +
"\"TelNum\":\"" + TelNum + "\"," +
"\"email\":\"" + email + "\"," +
"\"Land\":\"" + Land + "\"," +
"\"Plaats\":\"" + Plaats + "\"," +
"\"PostCode\":\"" + PostCode + "\"}";
MessageBox.Show(json);
}
sw.Write(json);
sw.Flush();
sw.Close();
}
This resulted in a failure ofcourse because it did nothing. This is bacause I have never used JSON before.
Can someone teach me a good method for this if it's posssible?