Advertisement
Guest User

Untitled

a guest
Feb 9th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. string query = "delete from myfusiontable where ROWID = 1"
  2. string sdata = "sql=" + HttpUtility.UrlEncode(query);
  3. ASCIIEncoding encoding = new ASCIIEncoding();
  4. byte[] data = encoding.GetBytes(sdata);
  5.  
  6. // Create the request, encode the query in the body of the post
  7. HttpWebRequest req = (HttpWebRequest)
  8. WebRequest.Create("https://www.googleapis.com/fusiontables/v2/query");
  9. req.Method = "POST";
  10. req.ContentType = "application/x-www-form-urlencoded";
  11. req.ContentLength = data.Length;
  12.  
  13. // Add the authentication header
  14. req.Headers.Add("Authorization: " + access_token);
  15. var t = req.Headers.AllKeys;
  16.  
  17. Stream sout = req.GetRequestStream();
  18. sout.Write(data, 0, data.Length);
  19. sout.Close();
  20. try
  21. {
  22. HttpWebResponse res = (HttpWebResponse)req.GetResponse();
  23. StreamReader stIn = new StreamReader(res.GetResponseStream());
  24. return stIn.ReadToEnd();
  25. }
  26. catch (WebException e)
  27. {
  28. StreamReader stIn = new StreamReader(e.Response.GetResponseStream());
  29. return stIn.ReadToEnd();
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement