web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to Increase JSON Maxlength

(0) ShareShare
ReportReport
Posted on by

Hi,

When we track a long email ( like 10 replies in that email) in CRM 2013 on premises . The Activities in Social Pane will cause an error.

Error: System.InvalidOperationException: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

  at System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object obj, StringBuilder output, SerializationFormat serializationFormat)

  at Microsoft.Crm.Application.Platform.Grid.GridDataProviderBase.PrepareJsonSerializedGridData(StringBuilder sbData)

  at Microsoft.Crm.Application.WebServices.AppGridWebServiceHandler.Refresh(String gridXml, StringBuilder sbXml, StringBuilder sbHtml, Boolean returnJsonData)

  at Microsoft.Crm.Application.WebServices.AppGridWebServiceHandler.ProcessRequestInternal(HttpContext context)


When I delete those long emails, It works fine again. But I want to increase the MaxJsonlength to avoid this errors but It didnt work. I tried to go to web.config and increased maxJosnLength to 2gb but it's still getting errors. The default is 1gb.

<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483647" />
<!-- 2GB limit -->
</webServices>
</scripting>
</system.web.extensions>

Do I need to go anywhere else to change to make it happen ? I am appreciated all the comments.

Thank you very much,

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Nizar JLASSI Profile Picture
    2 on at

    Hi Duc,

    try to add this line :

    <jsonSerialization maxJsonLength="2147483647" /> 

    in this block on web.config file:

    <location path="MSCRMServices">
      <system.web>
       <httpRuntime maxRequestLength="8192" />
         <webServices>
            <!-- HERE -->
            <soapExtensionReflectorTypes>
              <add type="Microsoft.Crm.Sdk.CrmServiceSoapExtensionReflector, Microsoft.Crm.WebServices" />
            </soapExtensionReflectorTypes>
            <conformanceWarnings>
            <remove name="BasicProfile1_1" />
          </conformanceWarnings>
       </webServices>
       <securityPolicy>
          <trustLevel name="Full" policyFile="internal"/>
       </securityPolicy>
      </system.web>
    </location>

    I hope that it can help you
    Nizar JLASSI
    Dymamics CRM Trainer and Senior Consultant
    Email : n.jlassi@gmail.com

    4TOOJYT41KG6.jpg        

  • Suggested answer
    Alessandro Graps Profile Picture
    2,664 on at

    <configuration>

      <system.web.extensions>

          <scripting>

              <webServices>

                  <jsonSerialization maxJsonLength="50000000"/>

              </webServices>

          </scripting>

      </system.web.extensions>

    </configuration>

    However if you use an iframe with mvc

    the MVC json serializer does not look at the webconfig to get the max length (thats for asp.net web services). you need to use your own serializer. you override ExecuteResult and supply you own json serializer. to override the input, create a new JsonValueProviderFactory, then override ValueProvider in the controller to return your new json factory when its a json request.

  • Alessandro Graps Profile Picture
    2,664 on at

    Hi,

    May you view this link

    rionscode.wordpress.com/.../comment-page-1

    Bye

    Alessandro

  • Community Member Profile Picture
    on at

    Thank you so much Nizar, It's fixed. I was so frustrated with this error for weeks.

  • Community Member Profile Picture
    on at

    Thank you for your comment Alessandro, I did some research about this but It didnt work. You can see Nizar's answer for reference.

  • Nizar JLASSI Profile Picture
    2 on at

    I'm happy for you.

    Good Luck.

    Nizar JLASSI
    Dymamics CRM Trainer and Senior Consultant
    Email : n.jlassi@gmail.com

             

  • Verified answer
    Community Member Profile Picture
    on at

    FYI this is supposed to be fixed in CRM2013 SP1 - here's the excerpt from the SP1 KB (support.microsoft.com/.../2941390)

    • When attempting to load activities on the Social Pane in Microsoft Dynamics CRM 2013 that have large amounts of text in the description, users encounter the following error: Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property.

  • Alan Smith Profile Picture
    on at

    Fast forward a couple of years to 2016. We use Dynamics CRM Online (version 7.1.1.4466 currently) aka 2015 Update. Associated with our usage of embedded ClickDimensions, we have seen this error when editing a ClickDimensions draft email message. 

    I'm not familiar with the suggested fix - edit web.config. Is that fix only applicable to on-premises CRM instances or can it be done on CRM Online instances by a CRM developer?

    thanks!

    snip_5F00_20160516090751.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans