Note that there are some explanatory texts on larger screens.

plurals
  1. POHttpClient posting byte[] to WCF service produces error: The maximum array length quota (16384) or the maximum items
    primarykey
    data
    text
    <p>I have a WCF service that can accept a <code>byte[]</code>. I'm creating a client using <code>HttpClient</code> and am receiving the following error. I've read online that you have to set the <code>readerQuotas</code> on both the server and the client, but how do I set these settings on the <code>HttpClient</code>?</p> <h3>Error:</h3> <blockquote> <p>There was an error deserializing the object of type RTM.API.Resources.UGCRequest. The maximum array length quota (16384) or the maximum items in object graph quota has been exceeded while reading XML data. These quotas may be increased by changing the MaxArrayLength property on XmlDictionaryReaderQuotas or the MaxItemsInObjectGraph setting.</p> </blockquote> <h3>Server Config:</h3> <pre class="lang-xml prettyprint-override"><code> &lt;standardEndpoints&gt; &lt;webHttpEndpoint&gt; &lt;standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647" maxBufferSize="2147483647"/&gt; &lt;standardEndpoint name="DirectoryEndpoint"/&gt; &lt;/webHttpEndpoint&gt; &lt;/standardEndpoints&gt; &lt;services&gt; &lt;service name="API.Service.UGCService" behaviorConfiguration="DataServiceBehavior"&gt; &lt;endpoint contract="API.Service.UGCService" kind="webHttpEndpoint" endpointConfiguration="" binding="webHttpBinding" bindingConfiguration="BigHttpBinding"/&gt; &lt;/service&gt; &lt;/services&gt; &lt;behaviors&gt; &lt;serviceBehaviors&gt; &lt;behavior name="DataServiceBehavior"&gt; &lt;serviceDebug includeExceptionDetailInFaults="true"/&gt; &lt;dataContractSerializer maxItemsInObjectGraph="2147483644"/&gt; &lt;/behavior&gt; &lt;/serviceBehaviors&gt; &lt;/behaviors&gt; &lt;bindings&gt; &lt;webHttpBinding&gt; &lt;binding name="BigHttpBinding" transferMode="Buffered" maxReceivedMessageSize="2147483647" &gt; &lt;readerQuotas maxArrayLength="2147483647" maxDepth="2147483647" maxStringContentLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/&gt; &lt;/binding&gt; &lt;/webHttpBinding&gt; &lt;/bindings&gt; </code></pre> <h3>Client code:</h3> <pre class="lang-cs prettyprint-override"><code>using (HttpClient client = new HttpClient(apiPath)) { using (HttpRequestMessage request = new HttpRequestMessage(method, finalUrl)) { request.Headers.Accept.AddString("application/json"); request.Headers.Add("Authorization", sb.ToString()); if (method == "POST" || method == "PUT") { if (requestBody.Count() == 0) request.Headers.ContentLength = 0; else { request.Content = HttpContent.Create(APM6.Utils.Serialize(requestBody), "application/json"); } } using (HttpResponseMessage response = client.Send(request)) { return response.Content.ReadAsString(); } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload