In the previous post we’ve already discussed how to perform CRUD operations by sending HTTPS requests to SharePoint RESTful web services in PoweShell. The Invoke-RestSPO function was introduced for that purpose since Invoke-RestMethod cmdlet does not support claims based authentication and it makes this cmdlet impossible to use in O365 and SharePoint Online scenarios.
This time I am going to demonstrate how to perform basic create, read, update, and delete (CRUD) operations on folders and files with the SharePoint 2013 REST interface using Invoke-RestSPO function.
SharePoint 20123 Files and Folders REST syntax
Working with folders
Folder resource: represents a folder on a SharePoint Web site
Endpoint URI: http://<site url>/_api/web/getfolderbyserverrelativeurl(‘/<folder name>‘)
Supported HTTP methods: GET | POST | DELETE | MERGE | PUT
The following examples demonstrates how to perform basic CRUD operations with Folder resource.
Working with files
Folder resource: represents a file in a SharePoint Web site that can be a Web Part Page, an item in a document library, or a file in a folder.
Endpoint URI: http://<site url>/_api/web/getfilebyserverrelativeurl(‘/<folder name>/<file name>‘)
Supported HTTP methods: GET | DELETE | POST (File resource)
The following examples demonstrates how to perform basic operations with File resource including:
- upload file into SharePoint
- download file from a SharePoint
To summarize, it was demonstrates how to perform basic operations with files and folders, in particular how to download and upload files via REST. For that purpose we utilized Invoke-RestSPO function that is intended for sending HTTPS requests to O365/SharePoint Online REST service.
SharePoint 2013 introduces a Representational State Transfer (REST) service that is comparable to the SharePoint CSOM and in addition to CSOM, REST API opens up a huge capabilities, in particular for administering and automating SharePoint Online when used with PowerShell.
Sending REST requests to a SharePoint Online
In the previous post we’ve already covered how to perform read operations by sending HTTPS requests to SharePoint RESTful web services. This time we are going to extend PowerShell script in order to support all the CRUD operations.
The Invoke-RestSPO function sends HTTPS requests to SharePoint REST web services that returns richly structured data (JSON)
Since SharePoint requires the user to include a request digest value with each create, update and delete operation, an additional request is invoked using Get-SPOContextInfo function to request Context Info entity that contains request digest value.
In order to avoid an additional request, “*” eTag value is used to match any eTag value resulting in the operation being performed regardless of the actual value.
Lists manipulation using REST API in PowerShell
This section contains sample code for all of the CRUD operations.
Since SharePoint 2013 introduces a Representational State Transfer (REST) service that is comparable to the existing SharePoint client object models, it opens up a huge capabilities, in particular for administering and automating SharePoint Online when used with PowerShell.
My first idea was to utilize Invoke-RestMethod cmdlet, which was introduced in Windows PowerShell 3.0. Invoke-RestMethod cmdlet contains Credential parameter which could accept basic, digest, NTLM, and Kerberos authentication.
SharePoint Client Component SDK comes with a SharePointOnlineCredentials class which represents an object that provides credentials to access SharePoint Online resources. But unfortunately SharePoint Online credentials could not be passed in Invoke-RestMethod cmdlet, since claims based authentication is not supported by this cmdlet.
Below is demonstrated a simplified PowerShell script that to some extent mimics Invoke-RestMethod cmdlet. This script is intended for sending HTTPS request to a SharePoint Online REST service:
Previous two posts were devoted to discussion of how to integrate video from YouTube and another Video Providers into SharePoint. In the first post we have discussed how to store embedded video properties and render YouTube player using Computed Field. In the second one we have discussed how to store embed code itself as it was generated by Provider.
This time we will discuss at how you can aggregate video from RSS/Atom Feeds and provide some information about using API for retrieving video content from Video Providers.
Aggregating from Video Providers RSS/Atom Feeds using YouTube
When you retrieve a video feed or list of search results, YouTube returns an Atom feed. Below is presented description of how to display videos from YouTube Feed, in our case we will display results from YouTube channel only.
For retrieving video content and displaying results YouTube Viewer web part will be used here. In fact, it is just RSSAggregator web part, but with custom XSLT style sheet for processing YouTube feed, for details see implementation section.
So, let’s see how to add video from YouTube feed on page:
- Add YouTube Viewer web part which located under category Media Extensions on page
- Specify FeedUrl for YouTube channel, for example to display video feed from Critical Path Training specify value as shown on picture
- Result page with YouTube web part configured is shown below
Utilizing Video Providers API
The table below represents summary information about API for commonly used Video Providers listed in oEmbed.
Table 1. API support for Video Providers.
And for displaying it we need some logic to be implemented, for example by creating custom web part. Implementation details for this functionality are omitted here.
For aggregating and rendering YouTube Feeds RSSAggregator web part is used as was noted earlier with custom XSLT style sheet for processing YouTube Video Feeds.
To render YouTube feeds we provide custom XSLT style sheet by specifying XslLink property
and the following XSLT style sheet
The solution described here allows to embed video hosted on YouTube into SharePoint. The same approach may be applied for embedding video from another video hosting sites, for example from Vimeo.
The main idea here to store embedded video properties and not the embedded code itself.
For storing embedded video properties we will use Custom List, see implementation section for description. Page for Video Links list (default view with embedded player) is shown below
In order to embed a video into SharePoint:
- On YouTube site click the Share button located under the video.
- Click the Embed button.
- Copy at least src attribute value provided in the expanded box (see table 1 for supported attributes).
- Create new Video Link item and paste attribute values for embedded code into Video Links item. Save it.
Table 1. Mapping between embedded code iframe attributes and Video Link item
||Video Links field name
Video Links implementation
As was mentioned earlier only properties for embedded video code are stored and not the embedded code itself. For storing embedded video code properties is used Custom List that extends OOB Links List (TemplateType = 103)
For embedded video properties we create Video Link Content Type that inherits from Link CT (0x0105)
where we define the following fields
Pay attention, for rendering YouTube player Computed Field EmbeddedVideoOnForm is intended.
For rendering of a field on a List View the following XSLT style sheet is used
And finally, we create List Definition Video Links from Content Type Video Link. List schema and Template files for Video Links including whole project may be found on GitHub.
- Video Links project on GitHub
- How to embed Vimeo player see here
- How to embed YouTube player see here
- How to customize the rendering of a field in List View see here
Posted in SharePoint 2010
- Tagged Computed Field, Content Type, Custom List, Links List, List Definition, List Schema, List Template, SharePoint, SharePoint 2010, Vimeo, XSLT, YouTube
It is known that OOB Content Query Web Part (CQWP) renders results using Lists for arranging items as shown below
In ASP.NET WebForms for Web Control DataList there is a possibility to specify layout rendering mode using property RepeatLayout, what if the similar functionality would be available in CQWP?
So, our goal to extend CQWP, i.e. in addition to List Layout rendering mode, lets implement functionality for rendering Content Query Web Part results in Plain Old Table Layout.
In this approach, we would like to achieve the following options:
- Possibility to easily arrange results in columns
- Specify items direction (horizontal or vertical)
Content Query Web Part Class
Tool Part Class Implementation with the ability to specify Table Layout properties
Web Part manifest file
Pay attention that we provide custom XSLT for processing of the CQWP, for more details see How to: Customize XSL for the SharePoint Content By Query Web Part.
Main XSLT style sheet for rendering results in Table Layout
Below is shown Web Part configured to display results in 4 columns and horizontal mode layout
Sometimes in SharePoint we need to visualize hierarchical data as organizational chart. Prerequisites: not to use Flash or Silverlight technologies here.
So, in our scenario for storage of organization structure will be used SharePoint List based on Custom List , for rendering engine Google Chart Tools.
First, let’s take a look at list’s schema for storing organizational structure
||Used for parent/child relationship
||Display text for chart box
||Visual behavior for chart box
From Google Charts library we’ll use Organizational Chart package only.
1. Google Charts Tools loading and package initialization
2. Fetch data using SharePoint Web Service from list that contains organizational structure
3. Bind data source and draw chart
Result page with Org Structure rendered as Chart in List View
Context Data in Nintex Workflow represent values specific to the workflow, the context of the item and the current task within the workflow. As an example below are some of them
Initiator: The username (domain\username) who caused the item to be entered into the workflow
Item URL: The URL of the item in workflow
The complete list of Contex Data items and how to manage it is described in Nintex Workflow User Manual.
Designing custom Context Data usually include the implementation of specific handler(class). In Nintex Workflow API for this purposes exist class ContextDataItemBase, from which all Context Data items usually inherits.
The implementation of Context Data for returning approvers comments in XML format is presented below
Below is shown page for managing Context Data with custom Context Data added and Insert Reference dialog that demonstrates the usage of custom Context Data when designing workflow
Now our goal to automate the deployment of Context Data. For example, it is possible to create Data Context item during feature activation. For this task we’ll use method of class CustomCommonDataCollection (in namespace:Nintex.Workflow) from Nintex Workflow API:
Adding Context Data item in Nintex Workflow Management (shown below)
is equivalent to calling
You could grab the source code for the project that demonstrates how to provision Context Data here.
One of the options for creating workflows in Nintex Workflow 2010 (NW2010 for short) is to associate workflows with Content Types.This category of workflows is known as Reusable workflows.
As stated in Nintex Workflow 2010 User Manual
A resusable workflow template allows the workflow to be used on a content type, list or library through the
default SharePoint Workflow settings option.
Reusable workflow templates can be created for use within a single site or an entire site collection
In our case we are only interested in reusable workflows for content types.
Let’s disscuss the scenario when we need to automate the deployment of reusable workflow. It may take place for example, when there are several environments. The approach discussed here allows to deploy workflows during feature activation.
NW2010 API contains publishing infrastucture (Nintex.Workflow.Publishing namespace) that allow to programatically publish workflow templates.
Class Publish contains method
that allows to associate workflow using ContentTypeId parameter.
The method below demonstrate how to deploy reusable workflow file by passing it file name, contenttype name and workflow name(NWFMappingEntry parameter) using Nintex API PublishAWorkflow method.
Project that demonstrates how to deploy Nintex reusable workflows may be found here
Sometimes SharePoint PeopleEditor WebControl need to be initialized on the client side.
Initialize People Editor control
Clear People Editor control