GET data from SharePoint on-premise and POST data to SharePoint Online

1.1k Views Asked by At

I need to GET data from SharePoint Server 2019 (On-premise) list and then I need to add that data to the SharePoint Online list using CSOM.

I have found the below link to get data from SharePoint Server (On-premise) list. https://www.c-sharpcorner.com/article/sharepoint-client-object-modal-csom/

I have found below link to add data to SharePoint Online list. https://www.c-sharpcorner.com/blogs/create-a-list-item-in-sharepoint-using-csomannouncement-list

Is that correct way or do I need prefer another way?

Thanks

1

There are 1 best solutions below

0
Gaurav T On

If you just need list data without any version history or created/modified user and time stamps - you can export the SharePoint on-premise list to excel and use this excel file to create/import a new list in SharePoint Online.

Other options are to

  1. Use Microsoft's "SharePoint Migration Tool" to migrate content - this is a free tool provided by Microsoft - https://learn.microsoft.com/en-us/sharepointmigration/introducing-the-sharepoint-migration-tool
  2. use CSOM code in a VS application as per the links you have - note that you don't need to create 2 separate applications for it, just create one app and create separate instances of the ClientContext for SP on-prem and SP online
  3. use PnP PowerShell to get all list items and then loop over each item and create each item in target SPO site OR use SharePoint Powershell module to do the same. Here is an example of a script that migrates documents but with some minor modification you can get it to work with list data - https://github.com/alimughalx/CopySharePointFilesWithMetaDataAndVersionHistory