gitWebRequest.GetResponse()
行从服务器返回403 error
,我似乎无法弄清楚原因。任何帮助赞赏。
var address = new Uri(verifyUrl + _apiKey);
HttpRequest request = HttpContext.Current.Request;
var gitWebRequest = WebRequest.Create(address) as HttpWebRequest;
gitWebRequest.Method = "POST";
gitWebRequest.ContentType = "application/json";
var requestReader = new StreamReader(request.InputStream);
var requestBody = requestReader.ReadToEnd();
var myRequestUri = string.Format("{0}://{1}{2}",request.Url.Scheme,request.Url.Authority.TrimEnd('/'), request.RawUrl);
var verifyRequestData = new { requestUri = myRequestUri, postBody = requestBody };
var gitRequestData = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(verifyRequestData));
using (var stream = gitWebRequest.GetRequestStream())
{
stream.Write(gitRequestData, 0, gitRequestData.Length);
}
using (var response = gitWebRequest.GetResponse() as HttpWebResponse)
{
// Get the response stream
if (response != null)
{
var responseReader = new StreamReader(response.GetResponseStream());
result = responseReader.ReadToEnd();
}
}
答案 0 :(得分:0)
它使用的是http而不是https,这是goole所需要的。
感谢您让我查看网址。