Starts in:
2 DAYS
0 HR
59 MIN
33 SEC
Starts in:
2 D
0 H
59 M
33 S
Open Closed

REST API end-points not forming correctly #1463


User avatar
0
Neozzz created

The FileAppService is as shown below:

The IFileAppService is as shown below:

The File APIs formed are as shown below:

What might be the reason why the id fields shown before the name of the entity? Please let me know if I am missing something.

Thank you


6 Answer(s)
  • User Avatar
    0
    EngincanV created
    Support Team .NET Developer

    Hi @Neozzz, as stated here if you add an app service method named GetDocumentAsync it will calculates as /api/app/file/{id}/document but if you would specified it like GetAsync it would have transformed it into /api/app/file/{id}.

    • If you want to customize your route calculation, you can check here.
  • User Avatar
    0
    Neozzz created

    Hi @Neozzz, as stated here if you add an app service method named GetDocumentAsync it will calculates as /api/app/file/{id}/document but if you would specified it like GetAsync it would have transformed it into /api/app/file/{id}.

    • If you want to customize your route calculation, you can check here.

    Hi,

    Thank you for the reply. I am trying to submit a file from the swaffer ui to my appservice:

    public async Task<ObjectId> UploadImageAsync(IFormFile data)
            {
               bla bla
                return uploadSuccess;
            }
    

    But I get the following warning: System.IO.InvalidDataException: Missing content-type boundary.

    Full log on request:

    2021-06-29 09:57:29.330 +04:00 [DBG] Executing HealthCheck collector HostedService.
    2021-06-29 09:57:29.331 +04:00 [INF] Entity Framework Core 5.0.1 initialized 'HealthChecksDb' using provider 'Microsoft.EntityFrameworkCore.InMemory' with options: StoreName=HealthChecksUI 
    2021-06-29 09:57:29.331 +04:00 [INF] Start processing HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:57:29.331 +04:00 [INF] Sending HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:57:29.349 +04:00 [INF] Request starting HTTP/1.1 GET https://localhost:44354/health-status - -
    2021-06-29 09:57:29.350 +04:00 [INF] Executing endpoint 'Health checks'
    2021-06-29 09:57:29.571 +04:00 [INF] Executed endpoint 'Health checks'
    2021-06-29 09:57:29.572 +04:00 [INF] Request finished HTTP/1.1 GET https://localhost:44354/health-status - - - 200 - application/json 223.4216ms
    2021-06-29 09:57:29.590 +04:00 [INF] Saved 2 entities to in-memory store.
    2021-06-29 09:57:29.590 +04:00 [DBG] HealthReportCollector has completed.
    2021-06-29 09:57:29.590 +04:00 [DBG] HealthCheck collector HostedService executed successfully.
    2021-06-29 09:57:39.604 +04:00 [DBG] Executing HealthCheck collector HostedService.
    2021-06-29 09:57:39.605 +04:00 [INF] Entity Framework Core 5.0.1 initialized 'HealthChecksDb' using provider 'Microsoft.EntityFrameworkCore.InMemory' with options: StoreName=HealthChecksUI 
    2021-06-29 09:57:39.605 +04:00 [INF] Start processing HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:57:39.605 +04:00 [INF] Sending HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:57:39.625 +04:00 [INF] Request starting HTTP/1.1 GET https://localhost:44354/health-status - -
    ] Received HTTP response headers after 268.7558ms - 200
    2021-06-29 09:57:39.874 +04:00 [INF] End processing HTTP request after 268.9796ms - 200
    2021-06-29 09:57:39.875 +04:00 [DBG] HealthReportCollector - health report execution history saved.
    2021-06-29 09:57:39.875 +04:00 [DBG] HealthReport history already exists and is in the same state, updating the values.
    2021-06-29 09:57:39.875 +04:00 [INF] Saved 2 entities to in-memory store.
    2021-06-29 09:57:39.876 +04:00 [DBG] HealthReportCollector has completed.
    2021-06-29 09:57:39.876 +04:00 [DBG] HealthCheck collector HostedService executed successfully.
    2021-06-29 09:57:49.877 +04:00 [DBG] Executing HealthCheck collector HostedService.
    2021-06-29 09:57:49.877 +04:00 [INF] Entity Framework Core 5.0.1 initialized 'HealthChecksDb' using provider 'Microsoft.EntityFrameworkCore.InMemory' with options: StoreName=HealthChecksUI 
    2021-06-29 09:57:49.877 +04:00 [INF] Start processing HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:57:49.877 +04:00 [INF] Sending HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:57:49.902 +04:00 [INF] Request starting HTTP/1.1 GET https://localhost:44354/health-status - -
    2021-06-29 09:57:49.903 +04:00 [INF] Executing endpoint 'Health checks'
    2021-06-29 09:57:50.121 +04:00 [INF] Executed endpoint 'Health checks'
    2021-06-29 09:57:50.122 +04:00 [INF] Request finished HTTP/1.1 GET https://localhost:44354/health-status - - - 200 - application/json 220.8458ms
    2021-06-29 09:57:50.137 +04:00 [INF] Received HTTP response headers after 259.7043ms - 200
    2021-06-29 09:57:50.137 +04:00 [INF] End processing HTTP request after 259.8401ms - 200
    2021-06-29 09:57:50.138 +04:00 [DBG] HealthReportCollector - health report execution history saved.
    2021-06-29 09:57:50.138 +04:00 [DBG] HealthReport history already exists and is in the same state, updating the values.
    2021-06-29 09:57:50.138 +04:00 [INF] Saved 2 entities to in-memory store.
    2021-06-29 09:57:50.138 +04:00 [DBG] HealthReportCollector has completed.
    2021-06-29 09:57:50.138 +04:00 [DBG] HealthCheck collector HostedService executed successfully.
    2021-06-29 09:58:00.148 +04:00 [DBG] Executing HealthCheck collector HostedService.
    2021-06-29 09:58:00.149 +04:00 [INF] Entity Framework Core 5.0.1 initialized 'HealthChecksDb' using provider 'Microsoft.EntityFrameworkCore.InMemory' with options: StoreName=HealthChecksUI 
    2021-06-29 09:58:00.149 +04:00 [INF] Start processing HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:58:00.149 +04:00 [INF] Sending HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:58:00.167 +04:00 [INF] Request starting HTTP/1.1 GET https://localhost:44354/health-status - -
    2021-06-29 09:58:00.168 +04:00 [INF] Executing endpoint 'Health checks'
    2021-06-29 09:58:00.388 +04:00 [INF] Executed endpoint 'Health checks'
    <**trunc**>
    2021-06-29 09:58:10.679 +04:00 [INF] Saved 2 entities to in-memory store.
    2021-06-29 09:58:10.679 +04:00 [DBG] HealthReportCollector has completed.
    2021-06-29 09:58:10.679 +04:00 [DBG] HealthCheck collector HostedService executed successfully.
    2021-06-29 09:58:20.695 +04:00 [DBG] Executing HealthCheck collector HostedService.
    2021-06-29 09:58:20.695 +04:00 [INF] Entity Framework Core 5.0.1 initialized 'HealthChecksDb' using provider 'Microsoft.EntityFrameworkCore.InMemory' with options: StoreName=HealthChecksUI 
    2021-06-29 09:58:20.695 +04:00 [INF] Start processing HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:58:20.695 +04:00 [INF] Sending HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:58:20.714 +04:00 [INF] Request starting HTTP/1.1 GET https://localhost:44354/health-status - -
    2021-06-29 09:58:20.716 +04:00 [INF] Executing endpoint 'Health checks'
    2021-06-29 09:58:20.935 +04:00 [INF] Executed endpoint 'Health checks'
    2021-06-29 09:58:20.935 +04:00 [INF] Request finished HTTP/1.1 GET https://localhost:44354/health-status - - - 200 - application/json 221.4764ms
    2021-06-29 09:58:20.954 +04:00 [INF] Received HTTP response headers after 258.3474ms - 200
    2021-06-29 09:58:20.954 +04:00 [INF] End processing HTTP request after 258.4655ms - 200
    2021-06-29 09:58:20.954 +04:00 [DBG] HealthReportCollector - health report execution history saved.
    2021-06-29 09:58:20.955 +04:00 [DBG] HealthReport history already exists and is in the same state, updating the values.
    2021-06-29 09:58:20.955 +04:00 [INF] Saved 2 entities to in-memory store.
    2021-06-29 09:58:20.955 +04:00 [DBG] HealthReportCollector has completed.
    2021-06-29 09:58:20.955 +04:00 [DBG] HealthCheck collector HostedService executed successfully.
    2021-06-29 09:58:30.986 +04:00 [DBG] Executing HealthCheck collector HostedService.
    2021-06-29 09:58:30.986 +04:00 [INF] Entity Framework Core 5.0.1 initialized 'HealthChecksDb' using provider 'Microsoft.EntityFrameworkCore.InMemory' with options: StoreName=HealthChecksUI 
    2021-06-29 09:58:30.987 +04:00 [INF] Start processing HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:58:30.987 +04:00 [INF] Sending HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:58:31.007 +04:00 [INF] Request starting HTTP/1.1 GET https://localhost:44354/health-status - -
    2021-06-29 09:58:31.008 +04:00 [INF] Executing endpoint 'Health checks'
    2021-06-29 09:58:31.230 +04:00 [INF] Executed endpoint 'Health checks'
    2021-06-29 09:58:31.231 +04:00 [INF] Request finished HTTP/1.1 GET https://localhost:44354/health-status - - - 200 - application/json 223.5154ms
    2021-06-29 09:58:31.247 +04:00 [INF] Received HTTP response headers after 260.0129ms - 200
    2021-06-29 09:58:31.247 +04:00 [INF] End processing HTTP request after 260.1302ms - 200
    2021-06-29 09:58:31.247 +04:00 [DBG] HealthReportCollector - health report execution history saved.
    2021-06-29 09:58:31.248 +04:00 [DBG] HealthReport history already exists and is in the same state, updating the values.
    2021-06-29 09:58:31.248 +04:00 [INF] Saved 2 entities to in-memory store.
    2021-06-29 09:58:31.248 +04:00 [DBG] HealthReportCollector has completed.
    2021-06-29 09:58:31.248 +04:00 [DBG] HealthCheck collector HostedService executed successfully.
    2021-06-29 09:58:39.011 +04:00 [INF] Request starting HTTP/2 POST https://localhost:44354/api/app/file/upload-image multipart/form-data;+boundary=----WebKitFormBoundary1Ka0lYzBxmaVzIHU 77459
    2021-06-29 09:58:39.011 +04:00 [INF] CORS policy execution successful.
    2021-06-29 09:58:39.027 +04:00 [INF] Executing endpoint 'ZW.FileSvc.Files.FileAppService.UploadImageAsync (ZW.FileSvc.Application)'
    2021-06-29 09:58:39.027 +04:00 [INF] Route matched with {action = "UploadImage", controller = "File", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task`1[MongoDB.Bson.ObjectId] UploadImageAsync(Microsoft.AspNetCore.Http.IFormFile) on controller ZW.FileSvc.Files.FileAppService (ZW.FileSvc.Application).
    2021-06-29 09:58:39.464 +04:00 [ERR] ---------- RemoteServiceErrorInfo ----------
    {
      "code": null,
      "message": "An internal error occurred during your request!",
      "details": null,
      "data": {
        "ActivatorChain": "Castle.Proxies.FileAppServiceProxy"
      },
      "validationErrors": null
    }
    
    2021-06-29 09:58:39.464 +04:00 [ERR] An exception was thrown while activating Castle.Proxies.FileAppServiceProxy.
    Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.FileAppServiceProxy.
     ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Volo.Abp.Autofac.AbpAutofacConstructorFinder' on type 'Castle.Proxies.FileAppServiceProxy' can be invoked with the available services and parameters:
    Cannot resolve parameter 'ZW.FileSvc.Files.IFileRepository fileRepository' of constructor 'Void .ctor(Castle.DynamicProxy.IInterceptor[], ZW.FileSvc.Files.IFileRepository)'.
       at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable`1 parameters)
       at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
       at Autofac.Core.Activators.Reflection.ReflectionActivator.&lt;ConfigurePipeline&gt;b__11_0(ResolveRequestContext ctxt, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
       at Autofac.Builder.RegistrationBuilder`3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action`1 next)
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
       --- End of inner exception stack trace ---
       at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
     &lt;**trunc**&gt;
       at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.&lt;&gt;c__DisplayClass14_0.&lt;BuildPipeline&gt;b__1(ResolveRequestContext ctxt)
       at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)
       at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request)
       at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)
       at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
       at Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext)
       at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.&lt;&gt;c__DisplayClass5_0.&lt;CreateControllerFactory&gt;g__CreateController|0(ControllerContext controllerContext)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
       at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
    --- End of stack trace from previous location ---
       at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.&lt;InvokeNextExceptionFilterAsync&gt;g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
    2021-06-29 09:58:39.464 +04:00 [ERR] ---------- Exception Data ----------
    ActivatorChain = Castle.Proxies.FileAppServiceProxy
    
    2021-06-29 09:58:39.465 +04:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.Http.RemoteServiceErrorResponse'.
    2021-06-29 09:58:39.465 +04:00 [INF] Executed action ZW.FileSvc.Files.FileAppService.UploadImageAsync (ZW.FileSvc.Application) in 437.8322ms
    2021-06-29 09:58:39.465 +04:00 [INF] Executed endpoint 'ZW.FileSvc.Files.FileAppService.UploadImageAsync (ZW.FileSvc.Application)'
    2021-06-29 09:58:39.686 +04:00 [INF] Request finished HTTP/2 POST https://localhost:44354/api/app/file/upload-image multipart/form-data;+boundary=----WebKitFormBoundary1Ka0lYzBxmaVzIHU 77459 - 500 - application/json;+charset=utf-8 675.3065ms
    2021-06-29 09:58:41.266 +04:00 [DBG] Executing HealthCheck collector HostedService.
    2021-06-29 09:58:41.266 +04:00 [INF] Entity Framework Core 5.0.1 initialized 'HealthChecksDb' using provider 'Microsoft.EntityFrameworkCore.InMemory' with options: StoreName=HealthChecksUI 
    2021-06-29 09:58:41.267 +04:00 [INF] Start processing HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:58:41.267 +04:00 [INF] Sending HTTP request GET "https://localhost:44354/health-status"
    2021-06-29 09:58:41.286 +04:00 [INF] Request starting HTTP/1.1 GET https://localhost:44354/health-status - -
    2021-06-29 09:58:41.287 +04:00 [INF] Executing endpoint 'Health checks'
    2021-06-29 09:58:41.506 +04:00 [INF] Executed endpoint 'Health checks'
    2021-06-29 09:58:41.507 +04:00 [INF] Request finished HTTP/1.1 GET https://localhost:44354/health-status - - - 200 - application/json 221.2138ms
    
    
    

    Also there looks to be dependency injection error. So I'll give some context to the issue in the next thread.

  • User Avatar
    0
    Neozzz created

    What we're trying to do here is to use gridfs for storing files. And for that we dont require creating an entity. So there are some definitions we've to make at the several layers:

    For example, usually in the case of having an entity: public class MongoDbFileRepository :MongoDbRepository<BookStoreMongoDbContext, Author, Guid>, IFileRepository

    In our case we just used: public class MongoDbFileRepository : IFileRepository

    Could this be the cause of the dependency injection error?

    Is there any reference or example where we just capture data from from api and not use any entities?

    Please help.

    Thank you.

  • User Avatar
    1
    cotur created

    Hi, you can use IRemoteStreamContent for file upload & download actions.

    https://docs.abp.io/en/abp/latest/Application-Services#working-with-streams

  • User Avatar
    0
    cotur created

    What we're trying to do here is to use gridfs for storing files. And for that we dont require creating an entity. So there are some definitions we've to make at the several layers:

    For example, usually in the case of having an entity: public class MongoDbFileRepository :MongoDbRepository<BookStoreMongoDbContext, Author, Guid>, IFileRepository

    In our case we just used: public class MongoDbFileRepository : IFileRepository

    Could this be the cause of the dependency injection error?

    Is there any reference or example where we just capture data from from api and not use any entities?

    Please help.

    Thank you.

    About this issue,

    You can consider to create your own BLOB Provider. As you mentioned you want to use it for files.

    Here are detailed documentations.

    BLOB Storing BLOB Storing: Creating a Custom Provider

  • User Avatar
    0
    ServiceBot created
    Support Team Automatic process manager

    This question has been automatically marked as stale because it has not had recent activity.

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