Web API (official plugin)

Il y a 2 ans
WEB API v.1.06
THIS API return an ERROR message ...  
GET
https://....../api-backend/SpecificationAttributeOption/GetSpecificationAttributeOptionsBySpecificationAttribute/1

{
    "message": "Missing type map configuration or unsupported mapping.\r\n\r\nMapping types:\r\nObject -> CategoryDto\r\nSystem.Object -> Nop.Plugin.Misc.WebApi.Backend.Dto.Catalog.CategoryDto",
    "inner_exception_message": null,
    "stack_trace": "AutoMapper.AutoMapperMappingException: Missing type map configuration or unsupported mapping.\r\n\r\nMapping types:\r\nObject -> CategoryDto\r\nSystem.Object -> Nop.Plugin.Misc.WebApi.Backend.Dto.Catalog.CategoryDto\r\n   at lambda_method151467(Closure , Object , CategoryDto , ResolutionContext )\r\n   at Nop.Plugin.Misc.WebApi.Framework.Infrastructure.Mapper.Extensions.MappingExtensions.Map[TDestination](Object source)\r\n   at Nop.Plugin.Misc.WebApi.Framework.Infrastructure.Mapper.Extensions.MappingExtensions.ToDto[TBaseJsonDto](Object entity)\r\n   at Nop.Plugin.Misc.WebApi.Backend.Controllers.Catalog.SpecificationAttributeOptionController.<>c.<GetSpecificationAttributeOptionsBySpecificationAttribute>b__4_0(SpecificationAttributeOption c)\r\n   at System.Linq.Enumerable.SelectListIterator`2.MoveNext()\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\r\n   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\r\n   at Microsoft.AspNetCore.Mvc.Formatters.NewtonsoftJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)\r\n   at Microsoft.AspNetCore.Mvc.Formatters.NewtonsoftJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)\r\n   at Microsoft.AspNetCore.Mvc.Formatters.NewtonsoftJsonOutputFormatter.WriteResponseBodyAsync(OutputFormatterWriteContext context, Encoding selectedEncoding)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResultFilterAsync>g__Awaited|29_0[TFilter,TFilterAsync](ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResultExecutedContextSealed context)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.ResultNext[TFilter,TFilterAsync](State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeResultFilters()\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)\r\n   at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)\r\n   at Nop.Plugin.Misc.WebApi.Framework.Middleware.JwtMiddleware.InvokeAsync(HttpContext context, IWorkContext workContext, ICustomerService customerService)\r\n   at Nop.Plugin.Misc.WebApi.Framework.Middleware.ErrorHandlerMiddleware.InvokeAsync(HttpContext context)"
}

API of SpecificationAttribute return this:

https://...../api-backend/SpecificationAttribute/GetAll?pageIndex=0&pageSize=2147483647

{
    "total_count": 6,
    "total_pages": 1,
    "has_previous_page": false,
    "has_next_page": false,
    "items": [
        {
            "name": "MOD-SCALA-MG",
            "display_order": 1,
            "specification_attribute_group_id": 1,
            "id": 6
        },
        {
            "name": "MOD-CATEGORIA-MG",
            "display_order": 2,
            "specification_attribute_group_id": 1,
            "id": 7
        },
        {
            "name": "MOD-PRODUTTORE-MG",
            "display_order": 3,
            "specification_attribute_group_id": 1,
            "id": 1
        },
        {
            "name": "GIO-SOTTOFAMIGLIA - MG",
            "display_order": 4,
            "specification_attribute_group_id": 1,
            "id": 10
        },
        {
            "name": "GIO-GRUPPO - MG",
            "display_order": 5,
            "specification_attribute_group_id": 1,
            "id": 11
        },
        {
            "name": "GIO-FAMIGLIA-MG",
            "display_order": 6,
            "specification_attribute_group_id": 1,
            "id": 12
        }
    ],
    "page_index": 0,
    "page_size": 2147483647
}

All 6 specification attributes have specattributeoption values.

Example for specificationattributeid = 1

SELECT [Id]
       , [Name]
       , [ColorSquaresRgb]
       , [SpecificationAttributeId]
       , [DisplayOrder]
   FROM  [SpecificationAttributeOption]
   WHERE SpecificationAttributeId = 1

155 rows ...

Id  Name  ColorSquaresRgb  SpecificationAttributeId  DisplayOrder
1623  Abrex  NULL  1  225
1624  Academy  NULL  1  191
1625  Aedes Ars  NULL  1  217
1626  Airfix  NULL  1  30
1627  Amalgam  NULL  1  16
1628  Anson  NULL  1  27
1629  Apex Replicas  NULL  1  185
1630  Art Model  NULL  1  11
......

What could be the problem ? Thanks
Il y a 2 ans
Hi, Elicat1. This is a problem with the GetSpecificationAttributeOptionsBySpecificationAttribute method,  we'll fix it on the next version. If you want, you may fix it yourself just change CategoryDto to the SpecificationAttributeOptionDto in the ProducesResponseType attribute and in the call to the ToDto method

Elicat1 wrote:
WEB API v.1.06
THIS API return an ERROR message ...  
GET
https://....../api-backend/SpecificationAttributeOption/GetSpecificationAttributeOptionsBySpecificationAttribute/1
......
What could be the problem ? Thanks
Il y a 2 ans
Hi,

Right now it seems like if a user tries to authenticate with an MFA configured (Google Authenticator) the Web API doesn't support getting a JWT for the user since there's no option to enter the code when logging in. Is this something planned for a later version or are we missing something?
Il y a 2 ans
EmpireRich wrote:
Right now it seems like if a user tries to authenticate with an MFA configured (Google Authenticator) the Web API doesn't support getting a JWT for the user since there's no option to enter the code when logging in. Is this something planned for a later version or are we missing something?

No, we don't plan to support MFA in the near versions of the web API plugins
Il y a 2 ans
After updating to the V4.50.07 of the Web API Frontent, the Swagger page no longer displays any content.  The page loads however the following files are not found (404 error)

- swagger-ui.css
- swagger-ui-bundle.js
- swagger-ui-standalone-preset.js

Also, where can the source code be found for the Web API plugins, as they state it is available.
Il y a 2 ans
Hi, robjicom.

Source codes of plugins are available in the same archive in which the binary assembly is located.

As for the error: please describe how you updated the plugin, also check the version of the Microsoft.AspNetCore.Authentication.JwtBearer.dll library, it should be 5.0.13

robjicom wrote:
After updating to the V4.50.07 of the Web API Frontent, the Swagger page no longer displays any content.  The page loads however the following files are not found (404 error)

- swagger-ui.css
- swagger-ui-bundle.js
- swagger-ui-standalone-preset.js

Also, where can the source code be found for the Web API plugins, as they state it is available.
Il y a 2 ans
Hi Sergei,

OK, I found the source, I did not look into the .zip archives within the full archive file.  

As far as the installation, I copied the Misc.WebApi.Backend and Misc.WebApi.Frontend folders to the /Plugins folder.   After further testing I have found that if I install the Frontend API, the /api-frontend/index.html page displays as expected.  As soon as I install the Backend API, the /api-frontend/index.html does not display properly, and shows several resources as 404.  However, the /api-backend/index.html works fine.  If I uninstall the Backend API, the /api-frontend/index.html again works as expected.

Thanks!


Sergei-k wrote:
Hi, robjicom.

Source codes of plugins are available in the same archive in which the binary assembly is located.

As for the error: please describe how you updated the plugin, also check the version of the Microsoft.AspNetCore.Authentication.JwtBearer.dll library, it should be 5.0.13

After updating to the V4.50.07 of the Web API Frontent, the Swagger page no longer displays any content.  The page loads however the following files are not found (404 error)

- swagger-ui.css
- swagger-ui-bundle.js
- swagger-ui-standalone-preset.js

Also, where can the source code be found for the Web API plugins, as they state it is available.
Il y a 2 ans
WebApi v.1.06

Method  POST -->  /api-backend/Product/Create
don't auto-generate the "Search engine friendly page name" ( in table UrlRecord) by Product.Name .

Is there a specific setting missing
or
it is always necessary to use the specific method (after creating the product):

Method  POST --> /api-backend/UrlRecord/Create
{
  "entity_id": xxxx,
  "entity_name": "string",
  "slug": "string",
  "is_active": true,
  "language_id": 0,
  "id": 0
}

??

Thanks
Il y a 2 ans
Elicat1 wrote:
it is always necessary to use the specific method (after creating the product)...

Right. You have to manually invoke /api-backend/UrlRecord/Create
Il y a 2 ans
Hi, robjicom.
This is a known issue, please check the version of Microsoft.AspNetCore.Authentication.JwtBearer library in the NuGet package manager, it should be 5.0.13. If it is not, update it to the specified version.
robjicom wrote:
As soon as I install the Backend API, the /api-frontend/index.html does not display properly, and shows several resources as 404.  However, the /api-backend/index.html works fine.  If I uninstall the Backend API, the /api-frontend/index.html again works as expected.