Click here to Skip to main content
15,877,168 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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);




Anybody Help me to find Solution...Advance Thanks...
Posted
Updated 18-Jul-13 0:55am
v3
Comments
Bernhard Hiller 18-Jul-13 8:14am    
Are you sure that that's a problem of your client code? What about the server side? Do you have some other tool (e.g. browser interface) to send the same data to the service and then analyze the response?
Mohancs27 18-Jul-13 8:26am    
But i got server side response...Like Test String "Hi Mohan"...But i can't able to get any data from array which is i want...And one more thing is now i'm interacting with wamp server with PHP ...(Like .net with ISS 7 for myself and my interaction should be made with(PHP- WAMP Server)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900