I am trying to collect data from an open API for a Windows Phone application.
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); }
But I keep getting a ProtocolViolationException in the last line of the callback method with the message A request with this method cannot have a request body. . I read this because I am trying to send data that is obviously forbidden for the GET protocol, but I cannot see where I am doing it, i.e. How to avoid this.
source share