I need to do CRUD operations on SharePoint online lists (intranet) using REST api from a standalone Asp.Net application which is hosted completely outside office 365 (on on-premise).

I know that it is almost impossible using JavaScript, but my question is about using c#. Do I need to use username and password in the code? Or I have to solve the permission using OAuth or another technology?


1 Answer 1


If you want to perform CRUD operation on SharePoint Online lists, for that you can use C# code with console app or window app or else create web application.

The same requirement i was also having. So i used C# console application.

And yes you need to authenticate first, and for authentication you can use Username and Password into the code itself which will encrypt your credentials before sending over network. I used this mechanism for authentication.

For more details regarding Authentication you can refer this thread Authenticating client with office 365/SharePoint online

You can create the Provider Hosted App and using this you can perform CRUD operation on SharePoint Web Hosted list.

For getting started with SharePoint Provider Hosted App you can go through Get started creating provider-hosted SharePoint Add-ins

Let me know if i missed something in the answer.

If you want create a list item from outside the SharePoint Environment then you can use following code.

using (ClientContext clientContext = new ClientContext("your sharepoint online site url"))
                SecureString passWord = new SecureString();

                foreach (char c in "your password".ToCharArray()) passWord.AppendChar(c);

                clientContext.Credentials = new SharePointOnlineCredentials("your username", passWord);

                Web web = clientContext.Web;



                var myList = clientContext.Web.Lists.GetByTitle("your list name");
                ListItemCreationInformation listItemCreate = new ListItemCreationInformation();
                Microsoft.SharePoint.Client.ListItem newItem = myList.AddItem(listItemCreate);
                newItem["Title"] = "Item added by Job at " + DateTime.Now;



It worked for me. The above code is just console application. You can convert it into GUI also.

And for reference purpose you can refer this link Call O365 using CSOM with a Console Application

Let me know if you face any issue in running above code.

If you want to create an list item using REST API Service call then please refer this discussion CRUD Operations in Sharepoint Online using JavaScript on external site

  • Thank you Aakash, No I don't want to create Provider hosted app. Acctually it is about one of our partners which have a asp.net application. They want to change items inside a list of our SharePoint online directly from their web application. How can I achieve it?
    – Medes
    Commented Apr 27, 2016 at 9:01
  • Yes, it uses CSOM. I was wondering if it is possible do the same you wrote but using SPO REST API, not csom?
    – Medes
    Commented Apr 27, 2016 at 9:45
  • please check this discussion once sharepoint.stackexchange.com/questions/154020/… Commented Apr 27, 2016 at 9:58
  • So according to your link (the discussion thread), it is impossible to call sharepoint online api from a standalone application.
    – Medes
    Commented Apr 27, 2016 at 13:11
  • Its not like that @Medes. That link is just for information. Actuallly i am not confident hence i didn't added much description. Will update my answer again with valid code if thing is possible. :-) Commented Apr 27, 2016 at 14:24

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.