Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Getting Error While Creating A Record? #6412


User avatar
0
kalidarscope created

As per document(https://docs.aspnetzero.com/documents/zero/latest/Developing-Step-By-Step-Angular#creating-a-modal), i have created the modal to create a new section. When i click the save button, i am getting error like "An internal error occurred during your request".

Got the below info in browser console:

POST http://localhost:22742/api/services/app/Sections/CreateSection 500 (Internal Server Error)
abp.js:342 

ERROR: 

abp.js:342 {code: 0, message: "An internal error occurred during your request!", details: null, validationErrors: null}
service-proxies.ts:743 500

6 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    Check the error in Logs.txt.

  • User Avatar
    0
    kalidarscope created

    Got this error in log file.

    ERROR 2019-02-04 15:26:41,342 [8    ] Mvc.ExceptionHandling.AbpExceptionFilter - The field of type System.Int64 must be a string, array or ICollection type.
    System.InvalidCastException: The field of type System.Int64 must be a string, array or ICollection type.
       at System.ComponentModel.DataAnnotations.MaxLengthAttribute.IsValid(Object value)
       at System.ComponentModel.DataAnnotations.ValidationAttribute.IsValid(Object value, ValidationContext validationContext)
       at System.ComponentModel.DataAnnotations.ValidationAttribute.GetValidationResult(Object value, ValidationContext validationContext)
       at Microsoft.AspNetCore.Mvc.DataAnnotations.Internal.DataAnnotationsModelValidator.Validate(ModelValidationContext validationContext)
       at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.ValidateNode()
       at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.Visit(ModelMetadata metadata, String key, Object model)
       at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.VisitChildren(IValidationStrategy strategy)
       at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.VisitComplexType(IValidationStrategy defaultStrategy)
       at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.Visit(ModelMetadata metadata, String key, Object model)
       at Microsoft.AspNetCore.Mvc.ModelBinding.ObjectModelValidator.Validate(ActionContext actionContext, ValidationStateDictionary validationState, String prefix, Object model, ModelMetadata metadata)
       at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.EnforceBindRequiredAndValidate(ObjectModelValidator baseObjectValidator, ActionContext actionContext, ParameterDescriptor parameter, ModelMetadata metadata, ModelBindingContext modelBindingContext, ModelBindingResult modelBindingResult)
       at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value)
       at Microsoft.AspNetCore.Mvc.Internal.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext()
    --- End of stack trace from previous location where exception was thrown ---
       at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
       at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
    
  • User Avatar
    0
    aaron created
    Support Team

    Show DTO and actual input.

  • User Avatar
    0
    kalidarscope created

    My DTO:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Text;
    
    namespace Project.Sections.Dto
    {
        public class CreateSectionInput
        {
            [MaxLength(SectionsConsts.MaxEntryIdLength)]
            public long EntryId { get; set; }
    
            [MaxLength(SectionsConsts.MaxRecIdLength)]
            public string REC_ID { get; set; }
    
            [MaxLength(SectionsConsts.MaxSectionTextLength)]
            public string SECTION_TEXT { get; set; }
    
            [MaxLength(SectionsConsts.MaxDisplayOrdrLength)]
            public long DISPLAY_ORDER { get; set; }
    
            [MaxLength(SectionsConsts.MaxAttributeNameLength)]
            public string ATTRIBUTE_NAME { get; set; }
    
            [MaxLength(SectionsConsts.MaxDefaultBannerColorLength)]
            public string DEFAULT_BANNER_COLOR { get; set; }
    
            [MaxLength(SectionsConsts.MaxErrorBannerColorLength)]
            public string ERROR_BANNER_COLOR { get; set; }
    
            [MaxLength(SectionsConsts.MaxWarningBannerColorLength)]
            public string WARNING_BANNER_COLOR { get; set; }
    
            [MaxLength(SectionsConsts.MaxParentSectionRecIdLength)]
            public string PARENT_SECTION_RECORD_ID { get; set; }
    
            [MaxLength(SectionsConsts.MaxParentSectionTextLength)]
            public string PARENT_SECTION_TEXT { get; set; }
    
            [MaxLength(SectionsConsts.MaxTabRecordIdLength)]
            public string TAB_RECORD_ID { get; set; }
    
            [MaxLength(SectionsConsts.MaxTabTextLength)]
            public string TAB_TEXT { get; set; }
    
            [MaxLength(SectionsConsts.MaxPrimaryObjectRecordIdLength)]
            public string PRIMARY_OBJECT_RECORD_ID { get; set; }
    
            [MaxLength(SectionsConsts.MaxPrimaryObjectNameLength)]
            public string PRIMARY_OBJECT_NAME { get; set; } 
            
        }
    }
    
    
  • User Avatar
    1
    aaron created
    Support Team

    You cannot use MaxLength with long.

  • User Avatar
    0
    kalidarscope created

    Thanks @aaron