Developer forum

Forum » Dynamicweb 10 » dwapi/ecommerce/products?RepositoryName=SwiftProducts&QueryName=Products returns 204

dwapi/ecommerce/products?RepositoryName=SwiftProducts&QueryName=Products returns 204

Joakim Sjöbäck
Reply

running dw 10.0.26 and swift 1.25, when attemption to consume API via post dwapi/ecommerce/products?RepositoryName=SwiftProducts&QueryName=Products im getting 204 - No content

Index is built, and fetching products via group works fine.

 

What am I missing?

 

Thanks,

 


Replies

 
Joakim Sjöbäck
Reply

Bump

 
Joakim Sjöbäck
Reply
Json response:
{
    "type": "https://tools.ietf.org/html/rfc7231#section-6.6.1",
    "title": "System.NullReferenceException",
    "status": 500,
    "detail": "Object reference not set to an instance of an object.",
    "traceId": "00-d95dd7ed743aabeeb3fb56bb35f6f77f-9a0d9b8768b781a7-00",
    "exception": {
        "details": "System.NullReferenceException: Object reference not set to an instance of an object.\r\n   at Dynamicweb.Indexing.Lucene.LuceneIndexProvider.SearchInternal(IQuery query, QuerySettings settings)\r\n   at Dynamicweb.Indexing.Lucene.LuceneIndexProvider.Query(IQuery query, QuerySettings settings)\r\n   at Dynamicweb.Indexing.Queries.IndexQueryProvider.Query(IQuery query, QuerySettings settings)\r\n   at Dynamicweb.Indexing.Querying.QueryService.Query(IQuery query, QuerySettings settings)\r\n   at Dynamicweb.Ecommerce.ProductCatalog.ViewModelFactory.CreateView(ProductListViewModelSettings settings, IQuery query)\r\n   at Dynamicweb.Ecommerce.ProductCatalog.ViewModelFactory.CreateView(ProductListViewModelSettings settings, String repositoryName, String queryName)\r\n   at Dynamicweb.Frontend.Classic.Api.Products.Controllers.ProductsController.Search(SearchRequest searchRequest, ProductListViewModelSettings request)\r\n   at Dynamicweb.Frontend.Classic.Api.Products.Controllers.ProductsController.GetAll(SearchRequest search, ProductListViewModelSettings request)\r\n   at lambda_method78(Closure, Object, Object[])\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(ActionContext actionContext, IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()\r\n--- End of stack trace from previous location ---\r\n   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|25_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.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 NSwag.AspNetCore.Middlewares.SwaggerUiIndexMiddleware.Invoke(HttpContext context)\r\n   at NSwag.AspNetCore.Middlewares.RedirectToIndexMiddleware.Invoke(HttpContext context)\r\n   at Dynamicweb.Host.Core.Middleware.InitializersMiddleware.Invoke(HttpContext context)\r\n   at Dynamicweb.Host.Core.Middleware.LicenseMiddleware.Invoke(HttpContext httpContext)\r\n   at Dynamicweb.Host.Core.Middleware.InstallationMiddleware.Invoke(HttpContext httpContext)\r\n   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)",
        "headers": {
            "Accept": [
                "application/json, text/plain, */*"
            ],
            "Connection": [
                "close"
            ],
            "Host": [
                "localhost:5001"
            ],
            "User-Agent": [
                "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
            ],
            "Accept-Encoding": [
                "gzip, deflate, br"
            ],
            "Accept-Language": [
                "en-US,en;q=0.9,sv;q=0.8,no;q=0.7"
            ],
            "Cache-Control": [
                "no-cache"
            ],
            "Content-Type": [
                "application/json"
            ],
            "Cookie": [
                ".AspNetCore.Antiforgery.cOf_xUGa9yU=CfDJ8EAXqpSGTK9NpcxvPY7vMvWD3uEGcpk1_3ELvaJJb05_oH8GGmqsC9vERnlNgNltPQQpL9YoQyA-DvRO95vubBEMXe0CxXei3mwkg_bc6a31LPd2VWMZvNwgOOByUBjvkMTvVAYuyAN6LehcR4jAHog; __stripe_mid=c1dc87ac-92bc-45cc-825a-199ba99df804082040; cc_cookie={\"categories\":[\"necessary\",\"hotjar\"],\"level\":[\"necessary\",\"hotjar\"],\"revision\":0,\"data\":null,\"rfc_cookie\":false,\"consent_date\":\"2024-01-09T14:41:24.460Z\",\"consent_uuid\":\"3db5286d-3db1-4574-9f70-ffd7a8cabd8d\",\"last_consent_update\":\"2024-01-09T14:41:24.460Z\"}; .AspNetCore.Antiforgery.Sb85AdXv12E=CfDJ8EAXqpSGTK9NpcxvPY7vMvXzwo6FuKdGWBaA9dhUPgcXja0fXt60sxO3fK9zY25LPcydlJ0d_9UZI7AOZ6LRpssDFblYyARoe2IpauVzbrs-gnuN9713q_AX2sAS8OltFsmrO2G86_VI5C0QgXwrw-s; Dynamicweb.Admin=CfDJ8EAXqpSGTK9NpcxvPY7vMvWG8-t-TNDIYH1APDaYAEvcsTIMfZ7hzgsoaHs4KVt8IR-LfVyo5fitR69Ie8BtrQ97Y54MkxyxrlrEseNSP1CJ_IA5fjP9vzjozKW9rQ4is1Moy5OBrYtib89rmoPPE4iyFa_rdnWCna-iELifkKfr6z3ZzKYo_C9KUJ8pIQSRXf9qn3gZkApp5DAC7sdJumukf5sFoAfnjytmooSs5XMPpvJiQ5njpARxS3NhTb1a-ESSJqTH1IZtqIDPuOd9-EXYX4i9A64XQlDNkjkZfpBziu4KSioxEP9u-HM4A2glNUXXup8oGskFESyImQpxEJiW4WxdMbrz0KaNpa5cSLJIW0wYjbdITSoLsxvhZrXj0zUmNHJZez8OjtArlOi3XGvXqR71zuINkd4HMN4lMb841QKOR3VGvGB954T9l2RJtQ; CartSecret=60ab5a35f91a45fbabe951bd7bd13093; __stripe_sid=fbdbb0e9-ec81-4a02-a019-2fb41e87a82590241b; DW_Session_ID=f72e1865833041ddab8beab2eead092c48b039c43ac44f4a87847dbac1e8c361c19092fbff4a45f4a9447129a37fdbcd; _clck=1gavid1%7C2%7Cfig%7C0%7C1465; _clsk=hz1uzr%7C1705414447113%7C5%7C1%7Cs.clarity.ms%2Fcollect"
            ],
            "Origin": [
                "http://localhost:5173"
            ],
            "Pragma": [
                "no-cache"
            ],
            "Referer": [
                "http://localhost:5173/products"
            ],
            "Content-Length": [
                "110"
            ],
            "sec-fetch-dest": [
                "empty"
            ],
            "sec-fetch-mode": [
                "cors"
            ],
            "sec-fetch-site": [
                "same-origin"
            ],
            "sec-ch-ua-platform": [
                "\"Windows\""
            ],
            "sec-ch-ua-mobile": [
                "?0"
            ],
            "sec-ch-ua": [
                "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Google Chrome\";v=\"120\""
            ]
        },
        "path": "/dwapi/ecommerce/products",
        "endpoint": "Dynamicweb.Frontend.Classic.Api.Products.Controllers.ProductsController.GetAll (Dynamicweb.Frontend.Classic.Api.Products)",
        "routeValues": {
            "action": "GetAll",
            "controller": "Products"
        }
    }
}
 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Joakim

I have this reproduced - we are looking into this right away.

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

Hi Joakim,

I registered a bug #17168 to fix it asap

Best regards,
Vladimir

 
Joakim Sjöbäck
Reply

Any ETA on this fix?

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

Hi Joakim,

The fix is included in DW10.1 milestone 

Best regards,
Vladimir



 

 
Joakim Sjöbäck
Reply

Im currently testing 10.2 and this issue persists. 

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply

Hi Joakim,

Do you mean issue that Query Products returns 204?
I checked the Products query expressions, I suppose that the issue is due one whith ShopIDs parameter - try to disable it.
In usual flow - the value of context shop is detected via shop setting  of area  of current page, but in case of API request - the page is not defined, so macros return null value for that expression.

Best regards,
Vladimir

 
Joakim Sjöbäck
Reply

Yes dwapi/ecommerce/products/search?RepositoryName=SwiftProducts&QueryName=Products returns 204. Im not sure what you mean by disabling ShopIDs parameter?

Making the exact same request towards dw version 9.x correctly returns products.

 
Vladimir Shushunov Dynamicweb Employee
Vladimir Shushunov
Reply
This post has been marked as an answer

I mean this command:

 

Votes for this answer: 1
 
Joakim Sjöbäck
Reply

This solved the issue, thanks for the quick response.

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

You can also add the shopid to the query in the webapi using 

&ShopId=shop1
 
Joakim Sjöbäck
Reply

So not disabling shopId param and adding shopId to query should work? this still throws 204 for me.
/ecommerce/products/search?RepositoryName=SwiftProducts&QueryName=Products&PageSize=20&ShopId=SHOP1

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Joakim

If you query uses the SHOPID macro, you cannot get information out of it using the webapi as it uses the context of the pageview:

So instead, you add 'shopid' as a parameter to the query and use the parameter in a new OR group together with the ShopID macro.

BR Nicolai

 
Joakim Sjöbäck
Reply

Thanks for your patience, but im still having trouble fully understanding. Also earlier in thread you mentioned you had this reproduced.

I think i've taken the steps of adjustment but the issue still persists?

I must be missing something

 

You must be logged in to post in the forum