Search code examples
wcfwcf-binding

WCF REST Service Template 4.0 "Bad Request"


I am trying to send a large json string to a WCF Service created with the WCF REST Service Template. If the string is longer 8000 characters I get a "HTTP/1.1 400 Bad Request" error. I have tried added this to my web config:

    <bindings>
        <webHttpBinding>
            <binding name="httpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"/>
        </webHttpBinding>
    </bindings>

Any ideas?


Solution

  • You must also setup readerQuotas if you want to pass large strings:

    <bindings>
        <webHttpBinding>
            <binding name="httpBinding" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
               <readerQuotas maxStringContentLength="50000" />
            </binding>
        </webHttpBinding>
    </bindings>