private async Task <ActionResult> CreateAppModelData( string org, string app, Instance instance, string dataType) { Guid instanceGuid = Guid.Parse(instance.Id.Split("/")[1]); object appModel; string classRef = _appResourcesService.GetClassRefForLogicDataType(dataType); if (Request.ContentType == null) { appModel = _altinnApp.CreateNewAppModel(classRef); } else { appModel = ParseContentAndDeserializeServiceModel(_altinnApp.GetAppModelType(classRef), out ActionResult contentError); if (contentError != null) { return(contentError); } } // send events to trigger application business logic await _altinnApp.RunAppEvent(AppEventType.AppModelCreation, appModel); int instanceOwnerPartyId = int.Parse(instance.InstanceOwner.PartyId); DataElement dataElement = await _dataService.InsertFormData(appModel, instanceGuid, _altinnApp.GetAppModelType(classRef), org, app, instanceOwnerPartyId, dataType); SelfLinkHelper.SetDataAppSelfLinks(instanceOwnerPartyId, instanceGuid, dataElement, Request); return(Created(dataElement.SelfLinks.Apps, dataElement)); }