Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. public void TestMethod1()
  2. {
  3. HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://www.invoicera.com/app/api/xml/1.1/");
  4. request.Credentials = new NetworkCredential("MYKEY", "jj");
  5. request.Method = "POST"; // Post method
  6. request.ContentType = "text/xml";
  7. request.Accept = "application/xml";
  8.  
  9.  
  10. string xml = "<?xml version="1.0" encoding="utf-8"?><request method="getAccountInfo"></request>";
  11.  
  12. byte[] bytes = Encoding.UTF8.GetBytes(xml);
  13.  
  14. request.ContentLength = bytes.Length;
  15.  
  16. using (Stream putStream = request.GetRequestStream())
  17. {
  18. putStream.Write(bytes, 0, bytes.Length);
  19. }
  20.  
  21. using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
  22. using (StreamReader reader = new StreamReader(response.GetResponseStream()))
  23. {
  24. string resp = reader.ReadToEnd();
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement