Azure DevOps Server 2022.1 – JSON Serialization Fails Due to maxJsonLength Limit

Kapildev Gupta 0 Reputation points
2025-06-09T02:41:13.0133333+00:00

We are facing a persistent error in our on-premises Azure DevOps Server 2022.1 instance while saving or executing test runs in Test Plans.

The exact error is:
Error during serialization or deserialization using the JSON JavaScriptSerializer.

The length of the string exceeds the value set on the maxJsonLength property.

Parameter name: input

This happens even when splitting test cases into minimal steps and ensuring no attachments or rich content are added.

What We’ve Tried So Far:

Created and deployed a custom IHttpModule to override JavaScriptSerializer.MaxJsonLength = Int32.MaxValue.

Updated web.config with the module reference and restarted IIS.

Verified the module loaded without error.

Split test cases to reduce JSON payloads.

Confirmed the issue also occurs with very small and clean test cases.

Despite this, the error persists — indicating Azure DevOps internally serializes test metadata in a way that ignores global or IIS-level serializer configuration.

Azure DevOps
{count} votes

7 answers

Sort by: Most helpful
  1. Durga Reshma Malthi 4,430 Reputation points Microsoft External Staff Moderator
    2025-06-09T08:51:58.4633333+00:00

    Hi Kapildev Gupta

    Could you please try the below steps to resolve this issue.

    1. Microsoft has released Azure DevOps Server 2022 Patch 5, check if installing the latest patch resolves the issue.
    2. While you've already attempted to set MaxJsonLength in a custom IHttpModule, ensure that you have also set it in the correct section of the web.config file. Increase the request length in web.config:
         <configuration>
           <system.web>
             <httpRuntime maxRequestLength="2097151" />
           </system.web>
         </configuration>
      

    Hope this helps!

    Please Let me know if you have any queries.

    0 comments No comments

  2. Kapildev Gupta 0 Reputation points
    2025-06-10T04:50:17.6166667+00:00

    Hi Durga Reshma Malthi,

    Thanks for your response, I did upgrade to the latest patch and have rechecked the configuration, but still facing the same issue (ref ss).

    Any help in resolving this is really appreciated

    Thanks

    {57A3EB63-5C5E-4D03-9E4C-5D577E9006A1}

    {94DDB609-84C8-4293-BBFD-17496648F492}{889FBF23-075F-45C2-8DEB-1DCAEF965512}

    0 comments No comments

  3. Durga Reshma Malthi 4,430 Reputation points Microsoft External Staff Moderator
    2025-06-10T08:35:13.3966667+00:00

    Hi Kapildev Gupta

    Could you please follow the below steps to resolve this issue:

    1. Try to increase the maxJsonLength setting in your web config:
         <configuration> 
            <system.web.extensions>
                <scripting>
                    <webServices>
                        <jsonSerialization maxJsonLength="2147483647"/>
                    </webServices>
                </scripting>
            </system.web.extensions>
         </configuration> 
      
      Try modifying the web.config in all the locations. Example: C:\Program Files\Azure DevOps Server 2022\Application Tier\Web Services\web.config
    2. In some cases, Microsoft internally allows control of work item/test step size limits via registry keys. Try setting: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\TeamFoundationServer\19.0] "MaxJsonLength"=dword:7FFFFFFF Also try: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters] "MaxFieldLength"=dword:00010000 "MaxRequestBytes"=dword:01000000 Reboot the server or do iisreset afterward.
    3. Try restarting the services: Restart-Service TfsJobAgent Restart-Service TfsServerScheduler
    4. Split longer test cases into Shared steps and Parameter-based cases. This minimizes repeated content, reducing JSON serialization length.

    Additional References:

    https://stackoverflow.com/questions/1151987/can-i-set-an-unlimited-length-for-maxjsonlength-in-web-config

    Maxjsonlength

    Hope this helps!

    Please Let me know if you have any queries.

    If you found the information helpful, please click "Upvote" on the post to let us know and consider accepting the answer as the token of appreciation. Thank You.

    0 comments No comments

  4. Kapildev Gupta 0 Reputation points
    2025-06-10T09:26:22.6066667+00:00

    Hi Durga Reshma Malthi

    Thanks for the response,

    I am not able to understand how to and where to set these below values.

    Request you to please share the steps for updating on this

    Try setting: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\TeamFoundationServer\19.0] "MaxJsonLength"=dword:7FFFFFFF Also try: [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters] "MaxFieldLength"=dword:00010000 "MaxRequestBytes"=dword:01000000

    Thanks

    0 comments No comments

  5. Durga Reshma Malthi 4,430 Reputation points Microsoft External Staff Moderator
    2025-06-10T10:59:21.97+00:00

    Hi Kapildev Gupta

    To update these registry values, go to Registry Editor ->

    1. Navigate to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\TeamFoundationServer\19.0 -> Right-click in the right pane and select New -> DWORD (32-bit) Value -> Name it MaxJsonLength and double click and then set the Value Data to 7FFFFFFF. User's image
    2. Navigate to [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\Parameters] -> Right-click in the right pane and select New -> DWORD (32-bit) Value -> Name it MaxFieldLength and set the Value Data to 00010000 and also add MaxRequestBytes. with value 01000000

    Hope this helps!

    Please Let me know if you have any queries.

    If you found the information helpful, please click "Upvote" on the post to let us know and consider accepting the answer as the token of appreciation. Thank You.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.