Programatically download file from Teams SharePoint

Copper Contributor

I am migrating a project from a standalone SharePoint to one that is integrated with Teams.  My application currently downloads an XML file and may checkout and upload and check in.  


the current code to download does not work with the Teams SharePoint, i get 403 Forbidden errors. 


		public static XmlDocument GetConfig(string fileUrl)

			Uri fileUri = new Uri(fileUrl);

			string server = fileUri.AbsoluteUri.Replace(fileUri.AbsolutePath, "");
			string serverrelative = fileUri.AbsolutePath;
			XmlDocument doc = new XmlDocument();

				Microsoft.SharePoint.Client.ClientContext clientContext = new Microsoft.SharePoint.Client.ClientContext(server);
				Microsoft.SharePoint.Client.FileInformation f = Microsoft.SharePoint.Client.File.OpenBinaryDirect(clientContext, serverrelative);


                return doc;
            catch { }

            return null;


any suggestions?

2 Replies
Could you please provide more information regarding the issue you are facing.

@SteveAZ395, can you please help me understand which url are you passing in parameter?