In this SharePoint PnP tutorial, We will discuss the solution of an error as “The file you imported is not valid. Verify that the file is a web part description file (*.webpart or *.dwp) and that it contains well-formed XML“.
If you are new to PnP SharePoint tutorials, you can read below tutorials:
- SharePoint Online Development using Patterns and Practices (PnP)
- Create Folder and Subfolder in SharePoint Document Library using PnP Core CSOM Library
Recently, I was working with PnP SharePoint ASP.NET Web Application in Visual Studio 2017. There, I have added a Content Search Web Part using CSOM. To add this Content search web part, you have to map the content search file path from the web part gallery. I was mapping the file path as [string webPartXml = Server.MapPath(@”~/ContentSearch.webpart“);]
While I was running this CSOM code, an error occurred as “The file you imported is not valid. Verify that the file is a web part description file (*.webpart or *.dwp) and that it contains well-formed XML“. You can see the error message in below screenshot.
The file you imported is not valid. SharePoint verify that the file is a web part description file (*.webpart or *.dwp) and that it contains well-formed XML
The Solution of this above error is: You should save the Content Search file extension as “.xml” and map the file path as:
[string webPartXml = Server.MapPath(@”~/ContentSearch.xml”);]. Once you will pass this file Path and again run the code, then it will execute and give the appropriate result.
Hence in this SharePoint tutorial, We discussed the solution of an error as “The file you imported is not valid. verify that the file is a web part description file (*.webpart or *.dwp) and that it contains well-formed XML“. By using this above solution, You can overcome this type of issue.
You may like following SharePoint tutorials:
- PowerShell SharePoint Online: The remote server returned an error: (403) Forbidden
- Power BI Error: This content isn’t available
- An entry without a type name was found, but no expected type was specified error in Microsoft Flow
- The ETag of this item does not match the one used for setting content approval status error in Microsoft Flow
- Uncaught ReferenceError: web is not defined Error in SharePoint Online JSOM
- Column does not exist. it may have been deleted by another user error in SharePoint Online
- Error=Value=QuotaExceeded Tag=0x0121d3da SharePoint Online Office 365
- Error: “The operation could not be completed because the item was removed from the gallery” while adding a Custom Web part to a web part page in SharePoint 2016
- This computer is part of a farm error while uninstalling workflow manager 1.0 in SharePoint 2016/2013
I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site EnjoySharePoint.com
Idiot