public static void Main()
Console.WriteLine("Using REST in C#");
String url = "https://map-prototype.herokuapp.com/api/mapsList/";
String urlPost = "https://map-prototype.herokuapp.com/api/map/";
Console.WriteLine("GET");
Console.WriteLine(HttpGet(url));
String[] paramcpr = new String[2] {"cpr","map"};
String[] parammap = new String[2] {"xxxxxxxxxx","123"};
Console.WriteLine("POST");
Console.WriteLine(HttpPost(urlPost, paramcpr, parammap));
Console.WriteLine(HttpGet(url));
static string HttpGet(string url) {
HttpWebRequest req = WebRequest.Create(url) as HttpWebRequest;
using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
StreamReader reader = new StreamReader(resp.GetResponseStream());
result = reader.ReadToEnd();
static string HttpPost(string url, string[] paramName, string[] paramVal)
HttpWebRequest req = WebRequest.Create(new Uri(url)) as HttpWebRequest;
req.ContentType = "application/x-www-form-urlencoded";
StringBuilder paramz = new StringBuilder();
for (int i = 0; i < paramName.Length; i++) {
paramz.Append(paramName[i]);
paramz.Append(HttpUtility.UrlEncode(paramVal[i]));
byte[] formData = UTF8Encoding.UTF8.GetBytes(paramz.ToString());
req.ContentLength = formData.Length;
using (Stream post = req.GetRequestStream())
post.Write(formData, 0, formData.Length);
using (HttpWebResponse resp = req.GetResponse() as HttpWebResponse)
StreamReader reader = new StreamReader(resp.GetResponseStream());
result = reader.ReadToEnd();