Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Graham Davis 110 posts 376 karma points
    Feb 22, 2022 @ 00:52
    Graham Davis
    0

    The URL returned a 404 (not found): /umbraco/backoffice/umbracoapi/content/GetById-

    I have been having difficulty migrating a U8 Site to U9 and originally posted about it on the Umbraco Facebook group(link below)

    https://www.facebook.com/photo?fbid=10227095786723405&set=gm.1479985932403293

    As it turns out, there were orphaned records in the db that seem to have been the cause. My fix was to write a SQL Script that migrates the data from a U8 database to a Clean U9. I am including it below for anyone else that may benefit.

    I am still in the process of migrating the site. My problem is I am getting this error on the back end when I click on a page in the Content Tree:

    Request error: The URL returned a 404 (not found): /umbraco/backoffice/umbracoapi/content/GetById

    Any Ideas?

    Thanks!

    SQL SERVER MIGRATION SCRIPT

    =============================================    
    -- Author:  Graham Davis    
    -- Company: zBestData.com    
    -- Created: 02/18/2022    
    -- Updated: 02/18/2022 - Initial Script    
    --              
    -- Description: Convert Umbraco 8 Database to Umbraco 9     
    --              using a clean U9 MDF    
    -- =============================================
    
    SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoNode] ON;
    INSERT INTO[Umbraco9].[dbo].[umbracoNode] ([id]
          ,[uniqueId]
          ,[parentId]
          ,[level]
          ,[path]
          ,[sortOrder]
          ,[trashed]
          ,[nodeUser]
          ,[text]
          ,[nodeObjectType]
          ,[createDate])
    
    SELECT * FROM [Umbraco8].[dbo].[umbracoNode]
    WHERE id NOT IN (SELECT id FROM [Umbraco9].[dbo].[umbracoNode]); 
    SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoNode] OFF;
    
    SET IDENTITY_INSERT [Umbraco9].[dbo].[cmsContentType] ON;
    INSERT INTO[Umbraco9].[dbo].[cmsContentType] ([pk]
          ,[nodeId]
          ,[alias]
          ,[icon]
          ,[thumbnail]
          ,[description]
          ,[isContainer]
          ,[isElement]
          ,[allowAtRoot]
          ,[variations])
    
    SELECT * FROM [Umbraco8].[dbo].[cmsContentType] 
    WHERE pk NOT IN (SELECT pk FROM [Umbraco9].[dbo].[cmsContentType])
    SET IDENTITY_INSERT [Umbraco9].[dbo].[cmsContentType] OFF;
    
    INSERT INTO[Umbraco9].[dbo].[umbracoContent]( [nodeId]
          ,[contentTypeId])
    SELECT * FROM [Umbraco8].[dbo].[umbracoContent]
    WHERE contentTypeId IN (SELECT nodeId FROM [Umbraco9].[dbo].[cmsContentType]);
    
    INSERT INTO[Umbraco9].[dbo].[cmsContentNu] ([nodeId]
          ,[published]
          ,[data]
          ,[rv])
    SELECT * FROM [Umbraco8].[dbo].[cmsContentNu]
    WHERE nodeId  IN (SELECT nodeId FROM [Umbraco9].[dbo].[umbracoContent]);
    
    INSERT INTO[Umbraco9].[dbo].[cmsContentType2ContentType] ([parentContentTypeId]
          ,[childContentTypeId])
    SELECT * FROM [Umbraco8].[dbo].[cmsContentType2ContentType];
    
    INSERT INTO[Umbraco9].[dbo].[cmsContentType2ContentType] ([parentContentTypeId]
          ,[childContentTypeId])
     SELECT * FROM [Umbraco8].[dbo].[cmsContentType2ContentType]
     WHERE parentContentTypeId NOT IN (SELECT parentContentTypeId FROM [Umbraco9].[dbo].[cmsContentType2ContentType]);
    
     SET IDENTITY_INSERT [Umbraco9].[dbo].[cmsTemplate] ON;
    INSERT INTO[Umbraco9].[dbo].[cmsTemplate]([pk]
          ,[nodeId]
          ,[alias])
     SELECT * FROM [Umbraco8].[dbo].[cmsTemplate]
     SET IDENTITY_INSERT [Umbraco9].[dbo].[cmsTemplate] OFF;
    
    
     INSERT INTO[Umbraco9].[dbo].[cmsDocumentType] ([contentTypeNodeId]
          ,[templateNodeId]
          ,[IsDefault])  
    SELECT * FROM [Umbraco8].[dbo].[cmsDocumentType]
    WHERE [contentTypeNodeId]  IN (
    SELECT nodeId FROM [Umbraco9].[dbo].cmsContentType)
    
    INSERT INTO[Umbraco9].[dbo].[umbracoDocument] ( [nodeId]
          ,[published]
          ,[edited])
    SELECT * FROM [Umbraco8].[dbo].[umbracoDocument]
    WHERE nodeId IN ( SELECT nodeId FROM [Umbraco9].[dbo].[umbracoContent])
    
     SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoContentVersion] ON;
    INSERT INTO[Umbraco9].[dbo].[umbracoContentVersion] ([id]
          ,[nodeId]
          ,[versionDate]
          ,[userId]
          ,[current]
          ,[text])
          --,[preventCleanup])
          SELECT [id]
          ,[nodeId]
          ,[versionDate]
          ,[userId]
          ,[current]
          ,[text]
    FROM [Umbraco8].[dbo].[umbracoContentVersion] WHERE [current] = 1 
    AND nodeId IN ( SELECT nodeId FROM [Umbraco9].[dbo].[umbracoContent])
    SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoContentVersion] OFF;
    
    INSERT INTO[Umbraco9].[dbo].[umbracoContentSchedule]( [id]
          ,[nodeId]
          ,[languageId]
          ,[date]
          ,[action])
    SELECT * FROM [Umbraco8].[dbo].[umbracoContentSchedule];
    
    
    INSERT INTO[Umbraco9].[dbo].[umbracoDataType] ([nodeId]
          ,[propertyEditorAlias]
          ,[dbType]
          ,[config])
      SELECT * FROM [Umbraco8].[dbo].[umbracoDataType]
      WHERE nodeId NOT IN (SELECT nodeId FROM [Umbraco9].[dbo].[umbracoDataType]);
    
    INSERT INTO[Umbraco9].[dbo].[umbracoDocumentVersion] ([id]
        ,[templateId]
        ,[published])
    SELECT * FROM [Umbraco8].[dbo].[umbracoDocumentVersion] WHERE published = 1
    AND id IN (SELECT id FROM [umbracoContentVersion]);
    
    INSERT INTO[Umbraco9].[dbo].[umbracoMediaVersion] ([id]
          ,[paath])
      SELECT * FROM [Umbraco8].[dbo].[umbracoMediaVersion]
    
    SET IDENTITY_INSERT [Umbraco9].[dbo].[cmsPropertyTypeGroup] ON;
    INSERT INTO[Umbraco9].[dbo].[cmsPropertyTypeGroup] (id
          ,[uniqueID]
          ,[contenttypeNodeId]
          --,[type]
          ,[text]
          ,[alias]
          ,[sortorder])
    
    SELECT id
          ,[uniqueID]
          ,[contenttypeNodeId]
          --,[type]
          ,[text]
          ,[text] AS [alias]
          ,[sortorder]
    
    FROM [Umbraco8].[dbo].[cmsPropertyTypeGroup]
    WHERE id NOT IN (SELECT id FROM [Umbraco9].[dbo].[cmsPropertyTypeGroup]);
    SET IDENTITY_INSERT [Umbraco9].[dbo].[cmsPropertyTypeGroup] OFF;
    
    SET IDENTITY_INSERT [Umbraco9].[dbo].[cmsPropertyType] ON;
    INSERT INTO[Umbraco9].[dbo].[cmsPropertyType] ([id]
          ,[dataTypeId]
          ,[contentTypeId]
          ,[propertyTypeGroupId]
          ,[Alias]
          ,[Name]
          ,[sortOrder]
          ,[mandatory]
          ,[mandatoryMessage]
          ,[validationRegExp]
          ,[validationRegExpMessage]
          ,[Description]
          ,[labelOnTop]
          ,[variations]
          ,[UniqueID])
    
    SELECT * FROM [Umbraco8].[dbo].[cmsPropertyType] 
    WHERE id NOT IN (SELECT id FROM [Umbraco9].[dbo].[cmsPropertyType]);
    SET IDENTITY_INSERT [Umbraco9].[dbo].[cmsPropertyType] OFF;
    
    SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoPropertyData] ON;
    INSERT INTO[Umbraco9].[dbo].[umbracoPropertyData]([id]
          ,[versionId]
          ,[propertyTypeId]
          ,[languageId]
          ,[segment]
          ,[intValue]
          ,[decimalValue]
          ,[dateValue]
          ,[varcharValue]
          ,[textValue])
    SELECT * FROM [Umbraco8].[dbo].[umbracoPropertyData]
    WHERE versionId IN (SELECT ID FROM [Umbraco9].[dbo].[umbracoContentVersion]);
    SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoPropertyData] OFF;
    
    INSERT INTO[Umbraco9].[dbo].[umbracoRedirectUrl]([id]
          ,[contentKey]
          ,[createDateUtc]
          ,[url]
          ,[culture]
          ,[urlHash])
     SELECT * FROM [Umbraco8].[dbo].[umbracoRedirectUrl];
    
    SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoRelation] ON;
    INSERT INTO[Umbraco9].[dbo].[umbracoRelation] ([id]
          ,[parentId]
          ,[childId]
          ,[relType]
          ,[datetime]
          ,[comment])
    SELECT * FROM [Umbraco8].[dbo].[umbracoRelation];
    SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoRelation] OFF;
    
    
    SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoUser] ON;
    INSERT INTO[Umbraco9].[dbo].[umbracoUser] ([id]
          ,[userDisabled]
          ,[userNoConsole]
          ,[userName]
          ,[userLogin]
          ,[userPassword]
          ,[passwordConfig]
          ,[userEmail]
          ,[userLanguage]
          ,[securityStampToken]
          ,[failedLoginAttempts]
          ,[lastLockoutDate]
          ,[lastPasswordChangeDate]
          ,[lastLoginDate]
          ,[emailConfirmedDate]
          ,[invitedDate]
          ,[createDate]
          ,[updateDate]
          ,[avatar]
          ,[tourData])
     SELECT * FROM [Umbraco8].[dbo].[umbracoUser]
     WHERE id NOT IN (SELECT id FROM [Umbraco9].[dbo].[umbracoUser]);
     SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoUser] OFF;
    
    INSERT INTO[Umbraco9].[dbo].[umbracoUser2UserGroup] ([userId]
          ,[userGroupId])
    SELECT * FROM [Umbraco8].[dbo].[umbracoUser2UserGroup]
    WHERE userId NOT IN (SELECT userId FROM [Umbraco9].[dbo].[umbracoUser2UserGroup]);
    
    SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoUserGroup] ON;
    INSERT INTO[Umbraco9].[dbo].[umbracoUserGroup] ([id]
          ,[userGroupAlias]
          ,[userGroupName]
          ,[userGroupDefaultPermissions]
          ,[createDate]
          ,[updateDate]
          ,[icon]
          ,[startContentId]
          ,[startMediaId])
    SELECT * FROM [Umbraco8].[dbo].[umbracoUserGroup]
    WHERE ID NOT IN (SELECT id FROM [Umbraco9].[dbo].[umbracoUserGroup]);
    SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoUserGroup] OFF;
    
    SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoUserStartNode] ON;
    INSERT INTO[Umbraco9].[dbo].[umbracoUserStartNode] ([id]
          ,[userId]
          ,[startNode]
          ,[startNodeType])
    SELECT * FROM [Umbraco8].[dbo].[umbracoUserStartNode];
    SET IDENTITY_INSERT [Umbraco9].[dbo].[umbracoUserStartNode] OFF;
    
    SET IDENTITY_INSERT [Umbraco9].[dbo].[cmsMacro] ON;
    INSERT INTO[Umbraco9].[dbo].[cmsMacro] ([id]
          ,[uniqueId]
          ,[macroUseInEditor]
          ,[macroRefreshRate]
          ,[macroAlias]
          ,[macroName]
          ,[macroCacheByPage]
          ,[macroCachePersonalized]
          ,[macroDontRender]
          ,[macroSource]
          ,[macroType])
    SELECT * FROM [Umbraco8].[dbo].[cmsMacro];
    SET IDENTITY_INSERT [Umbraco9].[dbo].[cmsMacro] OFF;
    
    SET IDENTITY_INSERT [Umbraco9].[dbo].[cmsMacroProperty] ON;
    INSERT INTO[Umbraco9].[dbo].[cmsMacroProperty] ([id]
          ,[uniquePropertyId]
          ,[editorAlias]
          ,[macro]
          ,[macroPropertySortOrder]
          ,[macroPropertyAlias]
          ,[macroPropertyName])
     SELECT * FROM [Umbraco8].[dbo].[cmsMacroProperty];
     SET IDENTITY_INSERT [Umbraco9].[dbo].[cmsMacroProperty] OFF;
    
Please Sign in or register to post replies

Write your reply to:

Draft