我正在尝试从 Windows Phone 应用程序的公共 API 收集数据。
private void GatherPosts()
{
string url = baseURL + "?after=" + lastPostId + "&gifs=1";
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
request.ContentType = "text/json";
request.Method = "GET";
AsyncCallback callback = new AsyncCallback(PostRequestFinished);
request.BeginGetResponse(callback, request);
}
private void PostRequestFinished(IAsyncResult result)
{
HttpWebRequest request = (HttpWebRequest)result.AsyncState;
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);
}
ProtocolViolationException
但是我一直在回调方法的最后一行收到消息A request with this method cannot have a request body.
。我读到这是因为我正在尝试发送数据,这显然是 GET 协议禁止的,但我不知道我在哪里做,即如何避免它。