Developer forum

Forum » Feature requests » dwapi products search with POST

dwapi products search with POST

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

Can we have /dwapi/products/search accept POST (not just GET) requests?

 

The reason is because using we are using the dwapi to get product data for some B2B projects. But being B2B projects it's not unrealistic to have long product lists where the product ids can become large.

 

This is very common for us, since Swift uses the dwapi, so this limitation is becoming very aware for us, as the requests end up throwing a 404 when the GET request becomes too big.

 

Could this be added easily?

 

Best Regards,

Nuno Aguiar


Replies

 
Nicolai Pedersen
Reply

Hi Nuno

The POST /dwapi/ecommerce/products andpoint and GET /dwapi/ecommerce/products/search is exactly the same.

The POST endpoint do also need the 'SearchRequest' parameters as URL parameters in this case.
The POST endpoint then takes the ProductListViewModelSettings (a json object) as a request body.
That is the same as the additional parameters that you see from the GET endpoint that needs the parameters as querystring parameters:

You are probably using the ProductIds parameter on the GET endpoint which is the same querystring parameter on the POST endpoint, so that would not change things.

But - the endpoint works like this:

  • If RepositoryName and QueryName is specified, the index is searched
  • If GroupID is specified, products in the group is returned
  • If  ProductIds is specified, products with those IDs are returned

So to use the POST endpoint with a long range of ProductIds, you can create a Query that takes a parameter for productIDs - i.e. "NunosProductIds" and then on the post endpoint, specify the repository and query and add something like this to the request body (an instance of the ProductListViewModelSettings object)

{
  "Parameters": 
  {
    "NunoProductIds":"prod1,prod2,prod3"
  } 
}

BR Nicolai

 
Nicolai Pedersen
Reply

This is how the endpoints are specified:

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Nicolai,

 

Oh perfect, that must be it then. We actually tried to get the POST to work initially, but the difference in submitting ProuctIds as a querystring vs as a Query parameter (of the repository) was not clear until now.

 

We'll make the change and the world will be a happier place :)

 

Thanks,

Nuno Aguiar