I want to add a custom webapi service to sharepoint 2013. What I did so far is

  1. Create the webapi application
  2. Added an application in IIS
  3. Imported the webapi application

Tests are succesfull to get the data (from SP to service application), but now I would like to get the current logged in user from the SP context, in the service application. Is this possible? I tried using this SP contextprovider, used for apps, but I always receive a access denied error.

Any solutions for this?

FYI... I Can't just send the current user, because that would be a security threat

  • how did you add web api service in IIS?
    – samolpp2
    Commented Oct 4, 2016 at 13:19

1 Answer 1


Yes, it is possible - but you need to secure your service with SharePoint. You need to think SharePoint add-in or old school WCF service. For example:

  1. Develop your solution as a SharePoint provider-hosted add-in, e.g. using the SharePoint add-in MVC template in visual studio. Once the add-in is trusted and the user is authenticated, it is possible to obtain the current user through the SharePoint Client Side Object Model (CSOM) from your MVC controller service or from a webapi service.
  2. Develop a custom WCF service and deploy it to the ISAPI folder on folder SharePoint servers using a WSP solution package (not recommended anymore as this requires custom server-side changes to SharePoint).

I'm not going to provide examples here as they are plentiful already. But here are some places to start:

Building apps for SharePoint with MVC

An Architecture for SharePoint Apps That Call Other Services

Creating a custom WCF REST service for SharePoint 2013

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.