Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / productivity / SharePoint

When Uploading New Document, Getting Error Message as the URL is Invalid When Uploading Documents

5.00/5 (2 votes)
4 Jul 2016CPOL1 min read 11.2K  
This tip will help you to resolve an issue with Sharepoint document library. This error occurs when we create new document library and try to upload a document on it, else try to check in the document.

Introduction

I am getting an error message as the URL is invalid or it may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web. This error occurs when we create new document library and try to upload a document on it, else try to check in the document. The existing document libraries work fine with getting any error message.

Background

I tried the following ways to fix the issue:

  1. Verified the content type whether any duplicate columns are created or not
  2. Deactivated the custom content type solution and tried to upload the document
  3. Removed custom content type which is attached in the document library
  4. Tried to find out the issue on the log file
  5. Finally, I got Powershell script to resolve this issue

This issue occurred, duplicate column was created in the basic item content type.

Using the Code

Execute the below Powershell script in your SharePoint server to delete the duplicate column in the base content type.

PowerShell
if((Get-PSSnapin | Where {$_.Name -eq "Microsoft.SharePoint.PowerShell"}) -eq $null) {
Add-PSSnapin Microsoft.SharePoint.PowerShell;
}

$url = 'https://site.url.com'
Disable-SPFeature -Identity Fields -url $url -force
Enable-SPFeature -Identity Fields -url $url
$Site = get-spsite $url
foreach ($web in $site.allwebs)
{
    $lists = New-object System.collections.arraylist
    $web.Lists | % { $lists.add($_) } | Out-Null

    foreach ($list in $Lists)
    {
        $AuthorField = $list.fields.getfieldbyInternalName('Author')
        if ( $Authorfield.schemaXML -notmatch "FromBaseType" )
        {
            Write-host $web.url $list.title -Separator `t`t
            $xml = [xml]$AuthorField.SchemaXmlWithResourceTokens
            $xml.Field.SetAttribute('FromBaseType','TRUE')
            $AuthorField.SchemaXml = $xml.OuterXml
            $AuthorField.Update()
        }
    }
    }
$Site.Dispose()

After executing the above script, restart your IIS.

Points of Interest

I wasted lot of time to resolve this issue. I hope it will be helpful for you to resolve this issue within 2 to 3 minutes.

Please let me know if you are still facing the same issue.

History

  • 4th July, 2016: Initial version created

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)