【发布时间】:2014-07-04 08:07:39
【问题描述】:
我正在尝试使用谷歌云打印。云打印的/search api用于获取printerid和xsrf令牌..所以我发布数据并试图获得响应但每次我发布我都得到远程服务器返回错误:(403)禁止..是吗跨域问题还是什么问题?
string str= TextBox1.Text;
var request = (HttpWebRequest)WebRequest.Create("https://www.google.com/cloudprint/search?output=json&clientid=" + str);
request.Method = "POST";
SetupWebRequest (request);
string postData = "This is a test that posts this string to a Web server.";
byte[] byteArray = Encoding.UTF8.GetBytes (postData);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byteArray.Length;
Stream dataStream = request.GetRequestStream();
// Write the data to the request stream.
dataStream.Write(byteArray, 0, byteArray.Length);
// Close the Stream object.
dataStream.Close();
WebResponse response = request.GetResponse ();
【问题讨论】:
-
您的代码是否设法使用 c# 和谷歌云打印在特定打印机上打印???
标签: .net post httpwebrequest httpwebresponse google-cloud-print