Introduction

Creating custom REST-service for SharePoint and publishing it to SharePoint On-Prem farm.

Building the Sample

The solution is built using Visual Studio 2015 Office Developer Tools and designed to be deployed in SharePoint 2013 On-Premise. Also it's able to be deployed in SharePoint 2016 Server On-Premise.

This is farm solution and can not be deployed on SharePoint Online or convert to sandbox solution.

Description

SharePoint allows you to publish your custom REST-service and access it using HTTP requests from youe apps (Url addresses with the prefix _api). In addition, developers have the option to create your own REST services and publish them into SharePoint web applications.

These services are available via the HTTP requests of the form:

http://sharepoint/_api/CustomService

Access to your service's property CustomProperty:

http://sharepoint/_api/CustomService.CustomProperty

Or custom method CustomMethod:

http://sharepoint/_api/CustomService.CustomMethod

Published services can contain both properties and methods. Data can be presented in XML or JSON format. To retrieve data in JSON format just add the "Accept":"application/json;odata=verbose key-value pair in the request header.

More Information

Detailed description is available at my blog post (in Russian)http://blog.vitalyzhukov.ru/ru/sharepoint-custom-rest-api.aspx