none
problem while uploading Upload Large files(multiple attachements) using Rest Service(WebHttpBinding) to sharepoint library RRS feed

  • Question

  • Hi I am getting Bad Request Error(400) when try to upload files using Rest service to SharePoint library  in this case service call is failing,for small files it is working fine(service get called Properly).The problem is while trying to uploadmultiple files or document(in web part) service call get failed with 400 bad request protocol error Could you please help me out?

    Followings are my implementation for front end service call  and WCF service configuration.

     

      private static T NewMethod<T>()
            {
                WebHttpBinding webbind = new WebHttpBinding();
                webbind.MaxReceivedMessageSize = webbind.MaxBufferPoolSize = webbind.MaxBufferSize= int.MaxValue;
                webbind.ReceiveTimeout = webbind.OpenTimeout= new TimeSpan(0, 15, 0);
                webbind.MaxBufferSize = 2147483647;
                webbind.MaxReceivedMessageSize = 2147483647;
                webbind.MaxBufferPoolSize = 2147483647;
                webbind.ReaderQuotas.MaxStringContentLength = webbind.ReaderQuotas.MaxArrayLength = int.MaxValue;
                WebHttpBehavior behv = new WebHttpBehavior();
                behv.DefaultOutgoingRequestFormat = System.ServiceModel.Web.WebMessageFormat.Json;
                ChannelFactory<T> servFact = new ChannelFactory<T>(webbind, new EndpointAddress("http://localhost:6430/InboundCommHub.svc"));
                servFact.Endpoint.Behaviors.Add(behv);

                T servClient = servFact.CreateChannel();
                return servClient;
            }

         

            protected void Button2_Click(object sender, EventArgs e)
            {
                List<Files> fl = new List<Files> {
                    new Files(){Contents=FileUpload1.FileBytes,FileName =FileUpload1.FileName},
               
                    new Files(){Contents=FileUpload2.FileBytes,FileName =FileUpload2.FileName }
        
                };


                Complaint complain = new Complaint()
                {
                    ComplaintDescription = "Test Complaint from SharePoint",
                    FirstName = "Aniruddha",
                    LastName = "Bhattt",
                    Documents = fl.ToArray()

                };
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    IInboundCommHub servClient = NewMethod<IInboundCommHub>();
                    servClient.SubmitComplaintsToTempStore(complain);
                    (servClient as ICommunicationObject).Close();
                });

            }

    Web.config is

    <services>
          <service name="InboundCommunicationHub.InboundCommHub" behaviorConfiguration="ServiceBehavior">
            <endpoint address=""  binding="webHttpBinding"  bindingName="webBinding"
                                   contract="InboundServiceHelper.IInboundCommHub"
                                  behaviorConfiguration="web"></endpoint>
          </service>
        </services>
        <bindings>
          <webHttpBinding>
            <binding name="webBinding" maxBufferSize="2147483647"
                     maxBufferPoolSize="2147483647"
                     maxReceivedMessageSize="2147483647"
                     transferMode="Streamed" bypassProxyOnLocal="true" useDefaultWebProxy="false"
                     sendTimeout="00:20:00" closeTimeout="00:20:00" receiveTimeout="00:20:00">
              <readerQuotas  maxDepth="2147483647"
                             maxStringContentLength="2147483647"
                             maxArrayLength="2147483647"
                             maxBytesPerRead="2147483647"
                             maxNameTableCharCount="2147483647"/>
              <security mode="None" />
            </binding>
          </webHttpBinding>


        </bindings>

    Thursday, July 10, 2014 9:48 AM

Answers

  • Hi,

    I see that you have configured the webHttpBinding to allow transfer large data as following:

     <webHttpBinding>
             <binding name="webBinding" maxBufferSize="2147483647"
                      maxBufferPoolSize="2147483647"
                      .................................
             </binding>
           </webHttpBinding>
    But you have forgotten to apply this binding configuration to the endpoint, so you will meet the error, please try to modify your endpoint as following:
        <endpoint address=""   binding="webHttpBinding"  
    bindingConfiguration="webBinding"
    bindingName="webBinding" contract="InboundServiceHelper.IInboundCommHub" behaviorConfiguration="web"></endpoint>


    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, July 11, 2014 8:47 AM
    Moderator

All replies

  • Hi,

    I see that you have configured the webHttpBinding to allow transfer large data as following:

     <webHttpBinding>
             <binding name="webBinding" maxBufferSize="2147483647"
                      maxBufferPoolSize="2147483647"
                      .................................
             </binding>
           </webHttpBinding>
    But you have forgotten to apply this binding configuration to the endpoint, so you will meet the error, please try to modify your endpoint as following:
        <endpoint address=""   binding="webHttpBinding"  
    bindingConfiguration="webBinding"
    bindingName="webBinding" contract="InboundServiceHelper.IInboundCommHub" behaviorConfiguration="web"></endpoint>


    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, July 11, 2014 8:47 AM
    Moderator
  • Hi Amy,thanks for reply :) I will try and let you know :)


    Saturday, July 12, 2014 6:43 PM
  • Many Thanks Amy :) it works finally...................
    Monday, July 14, 2014 6:56 AM