Avata Suljettu

unsupported media type #6067


User avatar
0
mina luotu
  • ABP Framework version: v7.4
  • UI Type: Blazor WASM
  • Database System: EF Core (SQL Serve(
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes/no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

we have an Entity that inherit from FullAuditedEntity<int>, IHasConcurrencyStamp as follow

public abstract class TieredLayerBase : FullAuditedEntity&lt;int&gt;, IHasConcurrencyStamp
{
    [NotNull]
    public virtual string TieredLevelName { get; set; }
    public virtual decimal LowerLimit { get; set; }
    public virtual decimal? UpperLimit { get; set; }
    public virtual decimal Rate { get; set; }
    public int? BillingItemId { get; set; }
    public string ConcurrencyStamp { get; set; }

}

} and DTO than

public class TieredLayerCreateOrUpdateDto : FullAuditedEntityDto<int>, IHasConcurrencyStamp {

   //public int? Id { get; set; }
   [Required]
   public string TieredLevelName { get; set; } = null!;
   public decimal LowerLimit { get; set; }
   public decimal? UpperLimit { get; set; }
   public decimal Rate { get; set; }
   public int? BillingItemId { get; set; }

   public string? ConcurrencyStamp { get; set; } = null!;

}

AppService Interface as follow :Task<List<TieredLayerDto>> CreateTieredLayerToBillingItemAsync(List<TieredLayerCreateOrUpdateDto> tieredLayerCreateOrUpdateDtos);

and calling from blazor as follow await TieredLayersAppService.CreateTieredLayerToBillingItemAsync(NewTieredLayerList);

and we getting unsupported media type error message


12 Vastaus (t)
  • User Avatar
    0
    liangshiwei luotu
    Tukitiimi Fullstack Developer

    Can you provide the error logs?

  • User Avatar
    0
    mina luotu

    it is solved by separating the UpdateDto and the CreateDto, however, the use case is that we need to send a list of CreateOrUpdateDto to the Appservice and the decision should be taken there based on the Id value.

    in the browser is mentioned invalid value

    log is below

    2023-10-25 15:14:10.123 -04:00 [WRN] ---------- RemoteServiceErrorInfo ---------- { "code": null, "message": "Your request is not valid!", "details": "The following errors were detected during validation.\r\n - The tieredLayerCreateOrUpdateDto field is required.\r\n - '0x0A' is invalid within a JSON string. The string should be correctly escaped. Path: $[0] | LineNumber: 8 | BytePositionInLine: 5.\r\n", "data": {}, "validationErrors": [ { "message": "The tieredLayerCreateOrUpdateDto field is required.", "members": [ "tieredLayerCreateOrUpdateDto" ] }, { "message": "'0x0A' is invalid within a JSON string. The string should be correctly escaped. Path: $[0] | LineNumber: 8 | BytePositionInLine: 5.", "members": [ "$[0]" ] }

  • User Avatar
    0
    liangshiwei luotu
    Tukitiimi Fullstack Developer

    Hi,

    I can't reproduce the problem

    public abstract class TmAppService : ApplicationService
    {
        protected TmAppService()
        {
            LocalizationResource = typeof(TmResource);
        }
    }
    
    public class TestAppService : TmAppService, ITestAppService
    {
        public Task<TieredLayerCreateOrUpdateDto> TestAsync(TieredLayerCreateOrUpdateDto input)
        {
            return Task.FromResult(input);
        }
    }
    
    public class TieredLayerCreateOrUpdateDto : FullAuditedEntityDto<int>, IHasConcurrencyStamp
    {
    
       //public int? Id { get; set; }
       [Required]
       public string TieredLevelName { get; set; } = null!;
       public decimal LowerLimit { get; set; }
       public decimal? UpperLimit { get; set; }
       public decimal Rate { get; set; }
       public int? BillingItemId { get; set; }
    
       public string? ConcurrencyStamp { get; set; } = null!;
    }
    
    public interface ITestAppService: IApplicationService
    {
        Task<TieredLayerCreateOrUpdateDto> TestAsync(TieredLayerCreateOrUpdateDto input);
    }
    

  • User Avatar
    0
    mina luotu

    Hello, please find below the exact error we are getting in the browser console, in addition to the code

    {"error":{"code":null,"message":"طلبك غير صحيح!","details":"تم الكشف عن الأخطاء التالية أثناء التحقق .\r\n - The value 'layer-to-billing-item' is not valid.\r\n","data":{},"validationErrors":[{"message":"The value 'layer-to-billing-item' is not valid.","members":["id"]}]}}

    private async Task CreateLayerToBillingItemAsync(List<TieredLayerCreateOrUpdateDto> tieredLayerCreateOrUpdateDtos) {

       try
       {
           if (await NewTieredLayerValidations.ValidateAll() == false)
    
           {
               return;
           }
    
           await TieredLayersAppService.CreateLayerToBillingItemAsync(tieredLayerCreateOrUpdateDtos);
    
           await CloseCreateTieredLayerModalAsync();
    
       }
       catch (Exception ex)
       {
           await HandleErrorAsync(ex);
       }
    

    }

    public virtual async Task<List<TieredLayerDto>> CreateLayerToBillingItemAsync(List<TieredLayerCreateOrUpdateDto> tieredLayerCreateOrUpdateDtos) {

       if (tieredLayerCreateOrUpdateDtos != null && tieredLayerCreateOrUpdateDtos.Count > 0)
    
       {
           var tieredLayerDtosList = new List&lt;TieredLayerDto&gt;();
           foreach (var tieredLayerCreateOrUpdateDto in tieredLayerCreateOrUpdateDtos)
           {
               if (tieredLayerCreateOrUpdateDto.Id == 0)
               {
                   var tieredLayer = ObjectMapper.Map&lt;TieredLayerCreateOrUpdateDto, TieredLayer&gt;(tieredLayerCreateOrUpdateDto);
                   try
                   {
                       var tieredLayerReturn = await _tieredLayerManager.CreateAsync(
       tieredLayerCreateOrUpdateDto.BillingItemId, tieredLayerCreateOrUpdateDto.TieredLevelName, tieredLayerCreateOrUpdateDto.LowerLimit, tieredLayerCreateOrUpdateDto.Rate, tieredLayerCreateOrUpdateDto.UpperLimit
       );
    
                       var tieredLayerDto = ObjectMapper.Map&lt;TieredLayer, TieredLayerDto&gt;(tieredLayerReturn);
                       tieredLayerDtosList.Add(tieredLayerDto);
    
                   }
                   catch (Exception ex)
                   {
                       return new List&lt;TieredLayerDto&gt;();
                   }
               }
               else
               {
                   var tieredLayer = ObjectMapper.Map&lt;TieredLayerCreateOrUpdateDto, TieredLayer&gt;(tieredLayerCreateOrUpdateDto);
    
    
                   var tieredLayerUpdated = await _tieredLayerManager.UpdateAsync(tieredLayer.Id, tieredLayer.BillingItemId, tieredLayer.TieredLevelName, tieredLayer.LowerLimit, tieredLayer.Rate, tieredLayer.UpperLimit);
                   //var tieredLayerUpdated = await _tieredLayerRepository.UpdateAsync(tieredLayer);
                   var tieredLayerDto = ObjectMapper.Map&lt;TieredLayer, TieredLayerDto&gt;(tieredLayerUpdated);
                   tieredLayerDtosList.Add(tieredLayerDto);
    
    
               }
    
           }
           return tieredLayerDtosList;
       }
    
       return new List&lt;TieredLayerDto&gt;();
    
  • User Avatar
    0
    liangshiwei luotu
    Tukitiimi Fullstack Developer

    Hi,

    Can you share a minimal reproducible project with me? I will check it. shiwei.liang@volosoft.com

  • User Avatar
    0
    mina luotu

    sent GitHub Link by email

  • User Avatar
    0
    liangshiwei luotu
    Tukitiimi Fullstack Developer

    ok, please make the repo private.

  • User Avatar
    0
    mina luotu

    done

  • User Avatar
    0
    mina luotu

    Hello liangshiwei,

    I noticed that we changed the proxy setting to Static, it worked normally so I think it is an issue within the dynamic proxies, can you check this and advise the solution?

    also, we have a question regarding the ABP auto controller API, does it implement the service interface automatically in the controller or we should implement it ourselves?

    Thanks, Mina.

  • User Avatar
    0
    liangshiwei luotu
    Tukitiimi Fullstack Developer

    Because the parameter name is not the same, you should make sure they are the same

    we have a question regarding the ABP auto controller API, does it implement the service interface automatically in the controller or we should implement it ourselves?

    You can check the document: https://docs.abp.io/en/abp/latest/API/Auto-API-Controllers

  • User Avatar
    0
    mina luotu

    the Dynamics Proxy is solved but for the Static proxy, we are getting the below error, is that normal?

    Value cannot be null. (Parameter 'source') System.ArgumentNullException: Value cannot be null. (Parameter 'source') at Volo.Abp.Check.NotNull[T](T value, String parameterName) in D:\ci\Jenkins\workspace\abp-volo-release\abp\framework\src\Volo.Abp.Core\Volo\Abp\Check.cs:line 18 at System.Collections.Generic.AbpCollectionExtensions.AddIfNotContains[T](ICollection1 source, T item) in D:\ci\Jenkins\workspace\abp-volo-release\abp\framework\src\Volo.Abp.Core\System\Collections\Generic\AbpCollectionExtensions.cs:line 30 at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.AddGenericTypeUsingNamespace(String typeFullName, List1 usingNamespaceList) in D:\ci\Jenkins\workspace\abp-volo-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\CSharp\CSharpServiceProxyGenerator.cs:line 577 at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.AddGenericTypeUsingNamespace(String typeFullName, List1 usingNamespaceList) in D:\ci\Jenkins\workspace\abp-volo-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\CSharp\CSharpServiceProxyGenerator.cs:line 585 at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GetRealTypeName(String typeName, List1 usingNamespaceList) in D:\ci\Jenkins\workspace\abp-volo-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\CSharp\CSharpServiceProxyGenerator.cs:line 542 at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GenerateAsyncClassMethod(ActionApiDescriptionModel action, String returnTypeName, StringBuilder methodBuilder, List1 usingNamespaceList) in D:\ci\Jenkins\workspace\abp-volo-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\CSharp\CSharpServiceProxyGenerator.cs:line 334 at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GenerateClassMethod(ActionApiDescriptionModel action, StringBuilder clientProxyBuilder, List1 usingNamespaceList) in D:\ci\Jenkins\workspace\abp-volo-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\CSharp\CSharpServiceProxyGenerator.cs:line 274 at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GenerateClassFileAsync(GenerateProxyArgs args, ControllerApiDescriptionModel controllerApiDescription) in D:\ci\Jenkins\workspace\abp-volo-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\CSharp\CSharpServiceProxyGenerator.cs:line 219 at Volo.Abp.Cli.ServiceProxying.CSharp.CSharpServiceProxyGenerator.GenerateProxyAsync(GenerateProxyArgs args) in D:\ci\Jenkins\workspace\abp-volo-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\ServiceProxying\CSharp\CSharpServiceProxyGenerator.cs:line 146 at Volo.Abp.Cli.Commands.ProxyCommandBase`1.ExecuteAsync(CommandLineArgs commandLineArgs) in D:\ci\Jenkins\workspace\abp-volo-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\Commands\ProxyCommandBase.cs:line 57 at Volo.Abp.Cli.CliService.RunInternalAsync(CommandLineArgs commandLineArgs) in D:\ci\Jenkins\workspace\abp-volo-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\CliService.cs:line 169 at Volo.Abp.Cli.CliService.RunAsync(String[] args) in D:\ci\Jenkins\workspace\abp-volo-release\abp\framework\src\Volo.Abp.Cli.Core\Volo\Abp\Cli\CliService.cs:line 77

    D:\Business data2\Project\UtilityBillingSystemBW\src\UtilityBillingSystemBW.HttpApi.Client>

  • User Avatar
    0
    liangshiwei luotu
    Tukitiimi Fullstack Developer

    Hi,

    This is a bug with CLI, we will fix it: https://github.com/abpframework/abp/pull/18061

Made with ❤️ on ABP v8.2.0-preview Updated on maaliskuuta 25, 2024, 15.11