Error Cannot Send A Content-body With This Verb-type
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn cannot send a content-body with this verb-type powershell more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags
Cannot Send A Content-body With This Verb-type Httpclient
Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, powershell invoke-restmethod : cannot send a content-body with this verb-type. helping each other. Join them; it only takes a minute: Sign up Cannot send a content-body with this verb-type up vote 54 down vote favorite 12 I just got this exception (ProtocolViolationException) in my .NET 2.0 app (running cannot send a content body with this verb type ftp on windows mobile 6 standard emulator). What confuses me is that as far as i know, I have not added any content body, unless I've inadvertently done it somehow. My code is below (very simple). Is there anything else i need to do to convince .NET that this is just a http GET? Thanks, brian //run get and grab response WebRequest request = WebRequest.Create(get.AbsoluteUri + args); request.Method = "GET"; Stream stream = request.GetRequestStream(); // <= explodes
Cannot Send A Content Body With This Verb Type Json
here XmlTextReader reader = new XmlTextReader(stream); .net webrequest share|improve this question edited Jan 5 '15 at 8:15 Yuval Itzchakov 70.1k1990146 asked Oct 20 '10 at 19:28 Brian Sweeney 3,62893966 add a comment| 3 Answers 3 active oldest votes up vote 92 down vote accepted Don't get the request stream, quite simply. GET requests don't usually have bodies (even though it's not technically prohibited by HTTP) and WebRequest doesn't support it - but that's what calling GetRequestStream is for, providing body data for the request. Given that you're trying to read from the stream, it looks to me like you actually want to get the response and read the response stream from that: WebRequest request = WebRequest.Create(get.AbsoluteUri + args); request.Method = "GET"; using (WebResponse response = request.GetResponse()) { using (Stream stream = response.GetResponseStream()) { XmlTextReader reader = new XmlTextReader(stream); ... } } share|improve this answer edited Jul 11 '12 at 6:56 answered Oct 20 '10 at 19:30 Jon Skeet 899k48665247455 indeed that is exactly what i wanted to do. thanks. –Brian Sweeney Oct 20 '10 at 20:04 7 Technically, GET requests can have bodies, but .NET does not support generating GET reqeusts with bodies. stackoverflow.com/questions/2064281/… –mhud Jul 10 '12 at 22:23 1 @mhud: Thanks, will edit. –Jon Skeet Jul 11 '12 at 6:55 1 @JonSkeet You must be a genius or something. Th
here for a quick overview of the site Help content-length or chunked encoding cannot be set for an operation that does not write data. Center Detailed answers to any questions you might have powershell invoke-webrequest cannot send a content-body with this verb-type Meta Discuss the workings and policies of this site About Us Learn more about
Webclient Cannot Send A Content-body With This Verb-type
Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges http://stackoverflow.com/questions/3981564/cannot-send-a-content-body-with-this-verb-type Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Cannot send content-body with GET request up vote 0 down vote favorite I am http://stackoverflow.com/questions/27419728/cannot-send-content-body-with-get-request trying to execute a simple "request body search" on Elasticsearch like the following example but using .NET instead of curl $ curl -XGET 'http://localhost:9200/twitter/tweet/_search' -d '{ "query" : { "term" : { "user" : "kimchy" } } } ' Below is my .NET code. var uri = "http://localhost:9200/myindex/_search"; var json = "{ \"query\" : { \"term\" : { \"user\" : \"kimchy\" } } }"; var request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri); request.ContentType = "text/json"; request.Method = "GET"; var responseString = string.Empty; using (var streamWriter = new System.IO.StreamWriter(request.GetRequestStream())) { streamWriter.Write(json); streamWriter.Flush(); streamWriter.Close(); var response = (System.Net.HttpWebResponse)request.GetResponse(); using (var streamReader = new System.IO.StreamReader(response.GetResponseStream())) { responseString = streamReader.ReadToEnd(); } } However, I am getting the following error. Cannot send a content-body with this verb-type. ... Exception Details: System.Net.ProtocolViolationException: Cannot send a content-body with this verb-type. ... Line 54: using (var streamWriter = new System.IO.StreamWriter(request.GetRequestStream(
SQL Server 2014 Express resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel https://social.msdn.microsoft.com/Forums/en-US/02dd800a-a9cf-4dca-bb55-16b5672e12ff/cannot-send-a-contentbody-with-this-verbtype?forum=vstswebtest 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: Cannot send a content-body with this verb-type Archived Forums Visual Studio > cannot send Visual Studio Web Performance and Load Testing Question 0 Sign in to vote I had HTTP request with the following in the query string parameters:ProductAllocationIDs =3480 After executing the recorded web test, the request failed. The following was discovered in the details section System.Net.ProtocolViolationException: Cannot send a content-body with this verb-type. at System.Net.HttpWebRequest.CheckProtocol(Boolean onRequestStream) at System.Net.HttpWebRequest.BeginGetRequestStream(AsyncCallback callback, Object cannot send a state) at Microsoft.VisualStudio.TestTools.WebStress.WebTestTransaction.Execute(AsyncCallback completionCallback, Object callerState) Has anyone encountered this problem before? Tester Moved by David R. Williamson MSFTMicrosoft employee Friday, March 26, 2010 6:00 PM Web test (From:Visual Studio Team System - Testing) Tuesday, August 01, 2006 8:10 AM Answers 8 Sign in to vote Is there a form post parameter or a StringHttpBody on the request? That error message means you are trying to send request body data (such as form parameters or string body) when the method is set to GET. Try setting the method to POST and see if that fixes it. Josh Tuesday, August 01, 2006 2:36 PM All replies 0 Sign in to vote What does this mean? Is there a workaround? Tester Tuesday, August 01, 2006 8:12 AM 8 Sign in to vote Is there a form post parameter or a StringHttpBody on the request? That error message means you are trying to send request body data (such as form parameters or string body) when the method is set to GET. Try setting the