locked
Cannot send a content-body with this verb-type

    Question

  • 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 state)
       at Microsoft.VisualStudio.TestTools.WebStress.WebTestTransaction.Execute(AsyncCallback completionCallback, Object callerState)

    Has anyone encountered this problem before?

     

    Tester

    Tuesday, August 01, 2006 8:10 AM

Answers

  • 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

  • What does this mean?

    Is there a workaround?

    Tester

    Tuesday, August 01, 2006 8:12 AM
  • 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
  • Hi,

    If you have added any Form Post Parameter to the request and then deleted them all it it won't be enough. Seems the Web Test will still send some content in the body (haven't got time to verify what, use Fiddler or something if you like to find out. I run under ssl and Fiddler doesn't support ssl as we speak) and that is an invalid HTTP GET. Clear the empty tag <FormPostHttpBody /> from the .webtest file when viewed in a text editor, reload your project. Try again. Or like already said, change to POST method.

    Hope that will help you, it worked for me. /Regards Markus

    Tuesday, November 07, 2006 3:28 PM
  • Thanks for this info.  It sounds like you've poinpointed a bug for us.  I'll enter it in our system so we can fix it.

    Josh

    Tuesday, November 07, 2006 3:53 PM
  • Hello readers,

    i m working of screen scrapping application. i have below code.
    but i m not able to successfully do it with get method.

    please let me know if you found any solution.


     Dim reqflag As Boolean = False
    X:
            'requesturl = System.Web.HttpUtility.UrlDecode(requesturl)
            Dim webReq As HttpWebRequest = TryCast(WebRequest.Create(requesturl), HttpWebRequest)
            If requesturl.Contains("/pub/agent.dll?qscr=") Then
                'requesturl = requesturl.Insert(requesturl.Length, "&&&&BCheck=1&zz=" & App.GetTime.ToString)
                webReq.Method = "GET"
            Else
                webReq.Method = "GET"
            End If

            Try

           

                webReq.Accept = "*/*"
                'webReq.ContentType = "text/xml"
                webReq.UserAgent = "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)"
                webReq.Headers.Add("Accept-Language", "en-us")
                webReq.Headers.Add("UA-CPU", "x86")
                webReq.Headers.Add("Accept-Encoding", "gzip, deflate")
                'If requesturl = "http://www.expedia.com/pubspec/scripts/tealeafTarget.asp" Then
                '    webReq.Headers.Add("x-tealeaf", "ClientEvent")
                '    webReq.Headers.Add("x-tealeaf-page-render", "21680")
                '    webReq.Headers.Add("x-tealeaf-page-url", "Home Page")
                '    webReq.Headers.Add("x-tealeafsubtype", "undefined; INIT; BeforeUnload")
                '    webReq.Headers.Add("x-tealeaftype", "PERFORMANCE")
                '    webReq.Headers.Add("x-tealeaf-uieventcapture-version", "2008.3.24.1")
                '    webReq.Headers.Add("Pragma", "no-cache")
                'End If

                webReq.CookieContainer = cookiecollectio
                Dim postData As String = [String].Format(GetpostDataStream(paramList, resposeString))
                Dim requestWriter As New StreamWriter(webReq.GetRequestStream())
                requestWriter.Write(postData)
                requestWriter.Close()

                Dim responseReader As New StreamReader(webReq.GetResponse().GetResponseStream())
         
                Dim responseData As String = responseReader.ReadToEnd()

                If requesturl <> webReq.Address.AbsoluteUri AndAlso Not webReq.Address.AbsoluteUri Is Nothing AndAlso webReq.Address.AbsoluteUri <> "" Then
                    If Not reqflag Then
                        requesturl = webReq.Address.AbsoluteUri
                    End If
                    resposeString = responseData
                    GoTo X
                End If

    Wednesday, July 09, 2008 5:47 AM
  • You cannot use GET Method with a request body.

    Either (1) remove the request body, your code here:
                Dim requestWriter As New StreamWriter(webReq.GetRequestStream())

    Or (2) set the request Method to POST :

                webReq.Method = "POST"



    Hendy Irawan - http://www.HendyIrawan.com
    Sunday, December 27, 2009 4:21 PM
  • Hi!

     

    I'm using an API that requires me to use a GET request with parameters in the request body. The POST method is not allowed by the API. Is there anyway to send a GET request with a request body?

    Friday, March 26, 2010 9:39 AM
  • 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


    Thanks for sharing~I got the same error.

     


    Frank Xu Lei--谦卑若愚,好学若饥
    专注于.NET平台下分布式应用系统开发和企业应用系统集成
    Focus on Distributed Applications Development and EAI based on .NET
     

    老徐的网站】:http://www.frankxulei.com/

    老徐的博客】:http://www.cnblogs.com/frank_xl/

    【中文论坛】:微软WCF中文技术论坛
    【英文论坛】:微软WCF英文技术论坛

    Thursday, May 20, 2010 7:15 AM
  • yes, I hate API's that restrict use of a protocol (HTTP), because they have an certain interpretation of its use ("trying to help me").

    Ugh! WHY DOESN'T MS FIX THIS (i.e. remove restriction).

    Wednesday, September 22, 2010 5:12 PM
  • only way around this on MS platform is to shove whole XML doc (BASE64 encoded) in either custom header(ms-killing-me: <entire xml encoded) or QS (e.g. GET ... ?xmlbase64=<entire xml doc encoded>)
    Thursday, September 23, 2010 4:41 PM