{"id":213,"date":"2022-01-07T10:55:05","date_gmt":"2022-01-07T10:55:05","guid":{"rendered":"https:\/\/blog.citrus-lime.com\/crmc\/?p=213"},"modified":"2022-01-07T10:55:06","modified_gmt":"2022-01-07T10:55:06","slug":"sharepoint-client-object-model-max-message-size","status":"publish","type":"post","link":"https:\/\/blog.citrus-lime.com\/crmc\/sharepoint-client-object-model-max-message-size\/","title":{"rendered":"SharePoint Client Object Model \u2013 Max Message Size"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb_47144661.png\" alt=\"image\" \/><\/figure><\/div>\n\n\n\n<p>The SharePoint Client Object Model allows common SharePoint operations to be performed using a simple lightweight Webservice &#8211; and so is very useful when working with Apps that integrate with SharePoint, such as Dynamics CRM and Portals.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Client Object Model &#8211;&nbsp;<\/strong>This was introduced in SharePoint 2010 and then carried over into future versions of SharePoint.<\/p><\/blockquote>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/office\/ee537247(v=office.14).aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/office\/ee537247(v=office.14).aspx<\/a><\/p><\/blockquote>\n\n\n\n<p>However if you use the SharePoint Object Model to allow your App or Service to upload Documents or other Files to SharePoint then you notice the following error:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Error whilst Uploading Document: The request message is too big. The server does not allow messages larger than 2097152 bytes.<\/strong><\/p><\/blockquote>\n\n\n\n<p>This is because the Default Setting for the Client Object Model in SharePoint 2013 is to limit single uploads to around 2MB in size. (2,097,512 bytes)<\/p>\n\n\n\n<p>To overcome this limitation, we have two options:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Rework our integration to &#8216;chunk&#8217; a file into several smaller uploads. (as opposed to a larger single upload)<\/li><li>Raise the 2Mb limit in SharePoint using a PowerShell Script.<\/li><\/ul>\n\n\n\n<p>If we look at how we can raise this limit, we need to run the following script past the SharePoint PowerShell:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>$ws = [Microsoft.SharePoint.Administration.SPWebService]::ContentService<br>$ws.ClientRequestServiceSettings.MaxReceivedMessageSize =&nbsp;<strong>10485769<\/strong><br>$ws.ClientRequestServiceSettings.MaxParseMessageSize&nbsp; =&nbsp;<strong>10485769<\/strong><br>$ws.Update()<\/p><\/blockquote>\n\n\n\n<p>This will raise the maximum upload size to 10MB for the Client Object Model.<\/p>\n\n\n\n<p>(not to be confused with general SharePoint Uploads which are controlled by the relevant setting in the Sites Virtual Application or individual Document Library)<\/p>\n\n\n\n<p>With this place, we can now see our larger uploads via the Client Object Model taking place successfully:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_28C98F6B.png\"><img decoding=\"async\" src=\"https:\/\/license.citruslime.com\/cs\/blogs\/crmcs\/image_thumb_362FA271.png\" alt=\"image\" title=\"image\" \/><\/a><\/figure>\n\n\n\n<p>The Client Object Model and Client-side Services are great components of SharePoint, and so the following articles and further reading may well be useful information on the topic.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Further Reading<\/h4>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Understanding the SharePoint 2010 Client Object Model<\/strong><\/p><p><a href=\"https:\/\/www.nothingbutsharepoint.com\/2011\/01\/20\/understanding-the-sp2010-client-object-model-aspx-2\/\">https:\/\/www.nothingbutsharepoint.com\/2011\/01\/20\/understanding-the-sp2010-client-object-model-aspx-2\/<\/a><\/p><p><strong>SharePoint 2013 .NET Server CSOM, JSOM and REST API Index<\/strong><\/p><p><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/office\/dn268594.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/office\/dn268594.aspx<\/a><\/p><p><strong>Using the Client Object Model<\/strong><\/p><p><a href=\"https:\/\/msdn.microsoft.com\/en-us\/library\/ff798388.aspx\">https:\/\/msdn.microsoft.com\/en-us\/library\/ff798388.aspx<\/a><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>The SharePoint Client Object Model allows common SharePoint operations to be performed using a simple lightweight Webservice &#8211; and so is very useful when working with Apps that integrate with SharePoint, such as Dynamics CRM and Portals. Client Object Model &#8211;&nbsp;This was introduced in SharePoint 2010 and then carried over into future versions of SharePoint.<\/p>\n","protected":false},"author":43,"featured_media":60,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"footnotes":""},"categories":[3,4],"tags":[],"class_list":{"0":"post-213","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-crm","8":"category-docdrive365"},"featured_image_src":"https:\/\/blog.citrus-lime.com\/crmc\/wp-content\/uploads\/sites\/30\/2021\/11\/Picture6.png","author_info":{"display_name":"jadesmith","author_link":"https:\/\/blog.citrus-lime.com\/crmc\/author\/jadesmith\/"},"_links":{"self":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/users\/43"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/comments?post=213"}],"version-history":[{"count":1,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/213\/revisions"}],"predecessor-version":[{"id":214,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/posts\/213\/revisions\/214"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/media\/60"}],"wp:attachment":[{"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/media?parent=213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/categories?post=213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.citrus-lime.com\/crmc\/wp-json\/wp\/v2\/tags?post=213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}