1

I am working in SharePoint Online with Office 365.

I need to create a REST API so that an external program is able to access data that I will have in a simple document library. It will have folders that goes only one level deep.

Also, our SharePoint online requires a username and password to access the main level site.

How do I ensure this works? What do I need on my end or on theirs?

I am really new to this. Please guide me how to achieve this?

Thank you for your help.

  • 1
    Will that RestAPI is anonymous or do you expect any authentication attached to it? – Sergei Sergeev Nov 9 '18 at 14:07
  • So the main sharepoint site requires authentication. Wen using postman, I receive a 403 error when trying to access the endpoint @SergeiSergeev – Michel Russell Nov 9 '18 at 14:21
  • 1
    Could you elaborate on what you're trying to achieve? You need access to SharePoint REST API from an external program, or do you need to create a custom REST API, which available to the outside world and to your external program (and that custom API also talks to SharePoint REST API)? – Sergei Sergeev Nov 9 '18 at 14:28
  • 1
    Sorry if it wasn't clear. I need to access Sharepoint List data from an external source using Rest AIs. – Michel Russell Nov 9 '18 at 14:33
  • Which language are you expecting to use? .NET? The external source is a desktop app or a web application? – Sergei Sergeev Nov 9 '18 at 14:38
1

You receive 403 in Postman because SharePoint requires authentication, either cookie based or oath via access tokens.

In most common case, if you want to send REST queries to SharePoint external from client-side javascript hosted somewhere, you should create azure ad application registration, then use adaljs library for authentication and request oauth access tokens for SharePoint resource.

You mentioned that the application is externally running web site. I guess it's not possible to implement azure ad auth to that site. In that case I would propose below solution for you:

  1. Create a custom web service, which gets data from SharePoint (using .NET code for example).
  2. From external web site use this custom web service for SharePoint related tasks.
  3. For SharePoint authentication from custom web service you can use either app security (client id and client secret) or use "system" user and utilize this user's credentials via SharePointOnlineCredentials.
  • Would you be able to explain how to do the steps you listed? – Michel Russell Nov 9 '18 at 17:42
  • 1
    I believe you should search further information over the internet, because "Create a custom web service" is too broad a topic, it depends on hosting, backend technology and other things... The way you interact with your custom service is also depends on web technology stack you use. I can't explain all the details here. I just gave you an overall implementation idea, digging into every step of it too complicated, time-consuming and subjective – Sergei Sergeev Nov 9 '18 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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