Click here to Skip to main content
15,888,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am pretty new to Restful WCF services so bear with me. I am trying to build a simple RESTful WCF service that returns a List of Students as json response.

In Response Approx 3842 Records are Showing when i invoke the same method in Browser but in actual List contains approx 9000 records.

Why response is truncated?
Posted

1 solution

hi one of two things....

Try setting maxJsonLength property on your web.config:

XML
<configuration>
   <system.web.extensions>
       <scripting>
           <webservices>
               <jsonserialization maxjsonlength="Large number here" />
           </webservices>
       </scripting>
   </system.web.extensions>
</configuration>


or because it is WCF you may want to look at the service behaviours. Try setting the maxitemsinobjectgraph property.

XML
<behaviors>
        <servicebehaviors>
            <behavior name="metadataBehavior">
                <servicemetadata httpgetenabled="true" httpgeturl="" />
                <servicedebug includeexceptiondetailinfaults="false" />
                <datacontractserializer maxitemsinobjectgraph="2147483646" />
            </behavior>
        </servicebehaviors>
    </behaviors>


you may find other examples from here :

http://geekswithblogs.net/mnf/archive/2013/06/02/response-for-rest-method-was-truncated-because-default-maxitemsinobjectgraph-was.aspx[^]
 
Share this answer
 
v2
Comments
Bhupendra Chauhan 19-Aug-14 7:28am    
Thanks. It works.
db7uk 19-Aug-14 7:42am    
great.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900