Open Closed

The key is empty in given json string. #1875


User avatar
0
ademaygun created
  • ABP Framework version: v4.3.3
    • ABP Suite version: v4.3.0
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no
  • **Volo.Abp.AbpException: The key is empty in given json string. at Volo.Abp.Localization.Json.JsonLocalizationDictionaryBuilder.BuildFromJsonString(String jsonString) at Volo.Abp.Localization.VirtualFiles.Json.JsonVirtualFileLocalizationResourceContributor.CreateDictionaryFromFileContent(String jsonString) at Volo.Abp.Localization.VirtualFiles.VirtualFileLocalizationResourceContributorBase.CreateDictionaryFromFile(IFileInfo file) at Volo.Abp.Localization.VirtualFiles.VirtualFileLocalizationResourceContributorBase.CreateDictionaries() at Volo.Abp.Localization.VirtualFiles.VirtualFileLocalizationResourceContributorBase.GetDictionaries() at Volo.Abp.Localization.VirtualFiles.VirtualFileLocalizationResourceContributorBase.GetOrNull(String cultureName, String name) at Volo.Abp.Localization.LocalizationResourceContributorList.GetOrNull(String cultureName, String name) at Volo.Abp.Localization.AbpDictionaryBasedStringLocalizer.GetLocalizedStringOrNull(String name, String cultureName, Boolean tryDefaults) at Volo.Abp.Localization.AbpDictionaryBasedStringLocalizer.GetLocalizedString(String name, String cultureName) at Volo.Abp.Localization.AbpDictionaryBasedStringLocalizer.GetLocalizedString(String name) at Volo.Abp.Localization.AbpDictionaryBasedStringLocalizer.get_Item(String name) at Volo.Abp.AspNetCore.Mvc.AbpDataAnnotationAutoLocalizationMetadataDetailsProvider.<>c__DisplayClass4_0.<CreateDisplayMetadata>b__0() at Microsoft.AspNetCore.Mvc.ModelBinding.Metadata.DefaultModelMetadata.get_DisplayName() at Microsoft.AspNetCore.Mvc.ModelBinding.ModelMetadata.GetDisplayName() at Microsoft.AspNetCore.Mvc.DataAnnotations.DataAnnotationsModelValidator.Validate(ModelValidationContext validationContext) at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.ValidateNode() at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.VisitSimpleType() at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.VisitImplementation(ModelMetadata& metadata, String& key, Object model) 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.VisitImplementation(ModelMetadata& metadata, String& key, Object model) at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.Visit(ModelMetadata metadata, String key, Object model) at Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.Validate(ModelMetadata metadata, String key, Object model, Boolean alwaysValidateAtTopLevel, Object container) at Microsoft.AspNetCore.Mvc.ModelBinding.ObjectModelValidator.Validate(ActionContext actionContext, ValidationStateDictionary validationState, String prefix, Object model, ModelMetadata metadata, Object container) at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.EnforceBindRequiredAndValidate(ObjectModelValidator baseObjectValidator, ActionContext actionContext, ParameterDescriptor parameter, ModelMetadata metadata, ModelBindingContext modelBindingContext, ModelBindingResult modelBindingResult, Object container) at Microsoft.AspNetCore.Mvc.ModelBinding.ParameterBinder.BindModelAsync(ActionContext actionContext, IModelBinder modelBinder, IValueProvider valueProvider, ParameterDescriptor parameter, ModelMetadata metadata, Object value, Object container) at Microsoft.AspNetCore.Mvc.Controllers.ControllerBinderDelegateProvider.<>c__DisplayClass0_0.<<CreateBinderDelegate>g__Bind|0>d.MoveNext() --- End of stack trace from previous location --- at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeInnerFilterAsync>g__Awaited|13_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) **:

I created entities with Abp Suite. I am trying to post entity with postman. But I got above error although name has value in json. If I remove [Required] exception losts.

public class ServiceBalanceChangeReasonCreateDto
{
    [Required]
    public string Name { get; set; }
}
public virtual async Task<ServiceBalanceChangeReasonDto> CreateAsync(ServiceBalanceChangeReasonCreateDto input)
{
...
...
}

EDIT : This error occurs on all Required usages in CreateOrUpdate..Dtos (all AppService methods) we got this error in all enviroments(debug,stage and prod)


3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I can't reproduce this problem, could you provide a simaple project to reproduce? thanks. shiwei.liang@volosoft.com

  • User Avatar
    0
    ademaygun created

    We found the problem. There was a line in en.json:

    "": "",
    

    I think in this case the error message doesn't describe exactly what the problem is.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    The key is empty in given json string.

    It looks like this error message is reasonable. PS ticket refunded

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09