c# - ProtocolViolationException when doing a WebRequest with GET -
i'm trying gather data public api windows phone app.
private void gatherposts() { string url = baseurl + "?after=" + lastpostid + "&gifs=1"; httpwebrequest request = webrequest.create(url) 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 keep getting protocolviolationexception
on last line of callback method message a request method cannot have request body.
. read it's because i'm trying send data, forbidden protocol, don't see i'm doing it, i.e. how avoid it.
it's contenttype
makes think there request body, exception.
you want set accept-encoding
instead.
Comments
Post a Comment