string url = "http://192.168.1.104/test.php"; string data = "{\"service\":\"absence.list\", \"company_id\":3}"; HttpWebRequest myReq =(HttpWebRequest )WebRequest.Create(url); myReq.Method = "POST"; myReq.ContentLength = data.Length; myReq.ContentType = "application/json; charset=UTF-8"; string usernamePassword = "YOUR API TOKEN HERE" + ":" + "x"; UTF8Encoding enc = new UTF8Encoding(); myReq.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(enc.GetBytes(usernamePassword))); using (Stream ds = myReq.GetRequestStream()) { ds.Write(enc.GetBytes(data), 0, data.Length); } WebResponse wr = myReq.GetResponse(); Stream receiveStream = wr.GetResponseStream(); StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8); string content = reader.ReadToEnd(); Response.Write(content);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)