Responsive Ads Here

Thursday, April 21, 2016

JSON Light support in REST SharePoint API

The REST SharePoint API has been an extremely popular way for Office 365 developers to work with SharePoint sites, lists/libraries, and list items/documents. One of the common feedback from developer’s community using the REST SharePoint API was about the payload of the data that was returned. The response from Microsoft was to add support for JSON Light. JSON Light is an open standard that allows developers to provide in the header of the request how much metadata is returned. To check out more about JSON Light, head over to the Microsoft OData JSON spec document. You can also check out all the endpoints for the SharePoint REST API over on MSDN.

Before this, when calling the SharePoint REST API, Office 365 developers had to include in the header request: “accept: application/json; odata=verbose”. This header is now optional, and more OData options have been added. If you don’t require all of the metadata for your business solution, you can significantly reduce the payload of your calls by using one of these other options. Take a look at this set of OData examples based on a common scenario of requesting a set of list items from a list and the associated response size.

Option 1: verbose

“accept: application/json; odata=verbose”46,647 bytes

Option 1 verbose


Option 2: minimalmetadata

“accept: application/json; odata=minimalmetadata”11,173 bytes

Option 2 minimalmetadata


Option 3: nometadata

“accept: application/json; odata=nometadata”6,832 bytes
The nometadata option reduces the size of the payload significantly, and for many scenarios this is all that you need when working with list items, for example.
Option 3 nometadata

Option 4: Don’t provide it

“accept: application/json”11,173 bytes
You are no longer required to provide the OData property in the request header, unless you would like to specify one of the values above. This defaults to minimalmetadata option.


Now, with support for JSON Light, you can choose the OData option you need for specific tasks and get an appropriately sized payload.


Saturday, August 22, 2015

Installing and Configuring SharePoint 2013 and SharePoint Farm

In one of the project I got a chance to set-up a SharePoint 2013 farm configuration for development environment (Hyper V) with below configuration.

  • Windows server 2012 R2
  • SQL Server 2014 

I never worked on configuration part, started typing in google Installing and configuring SharePoint 2013 and farm finally found some articles which will helped me lot to complete the 100% of task. Sad thing is I did not get a chance to document the same.


I found a nice article which contains complete step by step about preparing, installing, configuring the SharePoint 2013 farm with nice explanation.  This PDF has not contains the same configuration what I have mentioned above, its SharePoint 2013 configuration with windows server 2008 in VM ware environment. 

Please click here to download the same. 

Hope this post will be helpful.



Thursday, May 28, 2015

Get a one year free Office 365 developer account



Are you interested in Office 365 Developer Program? Do you want to get FREE!!! developer account? Microsoft gave us possibility to be a part of the Office 365 Developer Program for one year FREE subscription

The Office 365 Developer Program is a vibrant and growing community of developers, veteran and newbie, who are developing solutions on Office 365. I can confirm that Office 365 is still grooving and most of my projects right now are related to this platform.

 So if you interested in the program go this LINK and register. If you’d prefer to take some free, online training courses first, you have a chance at http://dev.office.com/training . Its’ very good move from Microsoft :).

So many videos have placed on APP Development, Boot Strap CSS and AngularJS. 

I hope this post will be helpful to you.....


Friday, May 1, 2015

SharePoint 2013 REST – Internet Explorer does not support this feed format

SharePoint 2013 adds the ability for you to remotely interact with SharePoint sites by using REST. Now, you can interact directly with SharePoint objects by using any technology that supports standard REST capabilities.

When I am reading resource(http://servername/_api/site) using REST API using Internet Explorer 10, I was getting error as below mentioned screen shot.




Root cause for the above error, if you have feed reading view on in your browser you will not able to see the XML.

I am using the browser IE 10, in order to view XML in IE 10, do the steps below.

1. Tools > Internet Options.

2. Select the Content Tab

3. Under Feeds and Web Slices, select Settings


4. Uncheck Turn on Feed reading view





     Then I was able to see the XML in the browser.

    

      Hope this post will be useful. 

Enabling the Developer Site Collection Feature in SharePoint On-premises / Online

In SharePoint 2013 we have a new site template called Developer Site Template, It is a site template which is used extensively for App development and you can only deploy apps for SharePoint to a Developer Site.

Developers can build, test and publish their apps here. Here you can deploy apps for SharePoint from Visual Studio 2013 to the developer site and you don't need to create an App Catalogue site since the developer site template by default creates an App Catalogue library. The developer template is available under the collaboration site template.

In one of the project, I got a scenario where I need to enable the developer site collection feature for a existing site collection it may be team site or publishing site. There isn't a button in the site collection features to let you enable this. 

If you were on premises environment, you'd just run the below command to enable the feature.

Enable-SPFeature e374875e-06b6-11e0-b0fa-57f5dfd72085 –url http://sp.contoso.com

But we can't do the same thing in SharePoint on-line site as the power shell commands doesn't expose the ability to turn features On and Off.

For this I have found a nice tool SharePoint Client Browser. It has an extremely useful feature to open up Power Shell with CSOM already loaded.

Find the step by step process to enable the feature mentioned below.

1. Click on SharePoint Client browser or run with admin privileges you can find Tenants and site collections. You can add by right click on any one of option. I am adding my site collection by giving user details. 



  
 2. One the authentication has been done, it will show the site collection like below image.

  



 3.  Right click on the site collection, it will show the option as Open Power Shell with CSOM.

    




Click on that it will open the power shell window as shown below.




It will ask the password again. Once you give the password, it will authenticate and show the sample code snippet also like below.




In the above screen grab,  we are able to see the sample code which will display the current site title and URL.



In the above screen grab,  I am loading the site and getting the feature id and adding the feature to the site. Find the complete snippet mentioned below.

$ctx.Load($ctx.Site);
$ctx.ExecuteQuery();
$guid = [System.Guid]"e374875e-06b6-11e0-b0fa-57f5dfd72085"
$ctx.Site.Features.Add($guid,$true,[Microsoft.SharePoint.Client.FeatureDefinitionScope]::None)
$ctx.ExecuteQuery();

For more details go through the below mentioned URL's.

http://blogs.msdn.com/b/kaevans/archive/2013/10/05/enabling-the-developer-site-collection-feature-in-sharepoint-online.aspx

https://mysharepointsolution.wordpress.com/2015/01/06/publish-app-to-non-developer-site-collection/

 Hope this post will helpful.

Tuesday, April 28, 2015

VS2013 Web Essentials - Zen Coding is a huge time saver for web developers

As a developer I'm always on the lookout for new solutions, tools, or techniques that can both boost my productivity. Last week I found a nice feature in visual studio 2013 which is Zen Coding.

As a web developer, I have regularly found myself needing to type a large amount of HTML layout code. Your page starts to grow, and your eyes begin to glaze over as you type DIV after DIV.


Zen Coding is a set of editor extensions, allowing a developer to use shorthand for common tasks. Microsoft has incorporated these extensions into Web Essentials for Visual Studio 2013.

I found a nice article which will give complete idea about this Zen Coding.



Friday, December 26, 2014

Adding Content Editor Web Part to Page in SharePoint programmatically

Content Editor Web Part is one of  useful OOB web part in SharePoint. 

You can use the Content Editor Web Part to add formatted text, tables, hyperlinks, and images to a Web Part Page.
  • The Content Editor Web Part is intended for adding HTML content to a Web Part Page, which may include hyperlinks. However, this Web Part is not designed to connect to a Web site. If you need to connect a Web Part to a Web site, consider using the Page Viewer Web Part.
  • The Content Editor Web Part does not accept the HTML FORM element. If you need to add a Web Part that uses the FORM element, consider using the Page Viewer Web Part or the Form Web Part.
 In my recent project i have a requirement to add content editor web part to the page programmatically.  We can add content editor web part  manually to page, but when we are moving from one environment to another environment its difficult to add to page manually.

In feature activation event i have written the below code snippet which will add the content editor web part to the page.   

/// Page Url for the Page
/// Web Part name for the same
/// Web Part height for the same
/// Zone id for the same
/// Zone index for the same
/// SPWeb Object
public static void AddContentEditorWebPartToPage(string pageUrl, string webpartName, string webpartHeight, string zone, int zoneId, SPWeb web)
{
            // TO DO : Check for existence of web part
   SPFile page = default(SPFile);
   bool webpartExistance = false;
   try
   {
     page = web.GetFile(pageUrl);
     if (page.Exists)
     {
       if (page.CheckOutType == SPFile.SPCheckOutType.Online)
       {
          throw new Exception("Page is already checked Out. Please check in or discard checkout before activating features");
       }

       page.CheckOut();
       using (SPLimitedWebPartManager manager = page.GetLimitedWebPartManager(PersonalizationScope.Shared))
       {
            string errorMessage = string.Empty;
            if (!web.IsRootWeb)
            {
               web = web.Site.RootWeb;
            }

            SPLimitedWebPartCollection webparts = manager.WebParts;
            foreach (System.Web.UI.WebControls.WebParts.WebPart webpart in webparts)
            {
                if (webpart.Title == webpartName)
                {
                  // Web Part found!
                  webpartExistance = true;
                  break;
                }                           
            }
            if (!webpartExistance)
            {
              //Creation of ContentEditor Webpart
              ContentEditorWebPart CEWP = new ContentEditorWebPart();
              CEWP.Title = webpartName;
              CEWP.Height = webpartHeight;
              CEWP.ChromeType = System.Web.UI.WebControls.WebParts.PartChromeType.None;
              XmlElement ProjectDetailsTitle = new XmlDocument().CreateElement("content");
              ProjectDetailsTitle.InnerText = @"
                                              
"; CEWP.Content = ProjectDetailsTitle; manager.AddWebPart(CEWP, zone, zoneId); manager.SaveChanges(CEWP); } } page.CheckIn("Adding WebParts", SPCheckinType.MajorCheckIn); page.Publish("Publishing Page"); } else { throw new Exception("Page Not found for adding web parts"); } } catch (Exception ex) { throw ex; } finally { // This is to ensure next time when feature is activated if there is error in previous activation its taken care if (page != null && page.CheckOutType == SPFile.SPCheckOutType.Online) { page.UndoCheckOut(); } } }


In the above code snippet, i am checking whether the page exists or not, if exists then we are checking whether the page is already checked out or not. If page is checked out throwing an exception. Other wise using limited web part manager we are checking for whether the page have already have the web part with the same name. If the web part exists we are skipping, other wise we are adding content editor web part to the page and finally we are doing the check in and publishing the page.

Hope this post will be useful..