CreateSimpleDocument return error 400 (Bad request) when I try to upload file bigger than 750KB

Using CWS web serices the method reateSimpleDocument() return error 400 (Bad Request) when I try to upload file bigger than 750 KB .

Instead if I use CreateDocumentContext(), all works fine I can archive in CS any kind of file without size limitation.

Her below the C# code.

      long sDocContext = 0;

      // Store the information for the local file

      ZetaLongPaths.ZlpFileInfo zfileInfo = null;

      try

      {

        //fileInfo = new FileInfo(sDocument);

        zfileInfo = new ZetaLongPaths.ZlpFileInfo(sDocument);

      }

      catch (Exception ex)

      {

        sError = "[+] " + sParent + "-" + sDocument + "-" + ex.Message;

      }

      // Create the DocumentManagement service client

      DocumentManagementClient docManClient = new DocumentManagementClient();

      // Create the OTAuthentication object and set the authentication token

      OTAuthentication otAuth = new OTAuthentication();

      otAuth.AuthenticationToken = sToken;

      Attachment ot_Att = new Attachment();

      try

      {

        // Create the FileAtts object to send in the upload call

        ot_Att.CreatedDate = zfileInfo.CreationTime;

        ot_Att.FileName = zfileInfo.Name;

        ot_Att.FileSize = zfileInfo.Length;

        ot_Att.ModifiedDate = zfileInfo.LastWriteTime;

        //ot_Att.Contents = File.ReadAllBytes(sDocument);

        ot_Att.Contents = zfileInfo.ReadAllBytes();

        sMessage += "[+] FileSize =" + zfileInfo.Length +  Environment.NewLine + "[+] CreatedDate =" + zfileInfo.CreationTime + Environment.NewLine + "[+] Name =" + zfileInfo.Name + "[+] LastWriteTime =" + zfileInfo.LastWriteTime + Environment.NewLine + Environment.NewLine;

        sMessage += "[+] sParent =>" + sParent + "<=" + Environment.NewLine;

        // *****************************************************************************************************

        sDocContext = docManClient.CreateSimpleDocument(ref otAuth, sParent, zfileInfo.Name, ot_Att);

        // *****************************************************************************************************

        sMessage = "  [+] Context ID created:" + sDocContext.ToString() + Environment.NewLine;

        return sDocContext.ToString();


      }

Comments

  • I think that’s how OT designed it isn’t it ? There’s a huge section dedicated in CWS explaining context methods and the Web. Config settings. One of the first posts in the CWS forum by Kyle Swidrowich has a pinned post on those aspects ... I believe
  • OT also has a simple attachment class which is inferior to the ContentService class that is used in higher upload requirements
  • Thanks Appu,

    I know there is a method CreateSimpleDocument which is used to have higher performance and it is the reason I would to use it! The problem is that seems there is a sort of block on the size only when I use this method. Anyway, I've found the problem in the CWS configuration: Web.congig --> maxReceivedMessageSize was only 1024000

            <binding name="DocumentManagementBinding" maxReceivedMessageSize="2147483647"

              messageEncoding="Text" transferMode="Buffered">

             <security mode="None">

             <transport clientCredentialType="None"/>

             </security>

            </binding>


    What is weird, the wrong configuration doesn't affect to the method CreateDocument .