Developer forum

Forum » Development » Fetching from the products & product endpoints

Fetching from the products & product endpoints

Snaevar Petursson
Snaevar Petursson
Reply

Greetings humans!

I've started to develop a vue frontend against the new DW API (wohoooo!) for our webshop
and ran into a bit of a problem with the products & product endpoints.

When using the endpoint "/dwapi/ecommerce/products" with a specified GROUPID i get this error
"The offset specified in a OFFSET clause may not be negative.".

Here is the Request URL 
"http://advaniavefverslun.local.dynamicweb.dk/dwapi/ecommerce/products?GroupId=GROUP210"

Here is the full stack trace:

at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)\r\n   
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)\r\n   
at System.Data.SqlClient.SqlDataReader.TryHasMoreRows(Boolean& moreRows)\r\n   
at System.Data.SqlClient.SqlDataReader.TryReadInternal(Boolean setTimeout, Boolean& more)\r\n   
at System.Data.SqlClient.SqlDataReader.Read()\r\n   
at Dynamicweb.Ecommerce.Products.ProductRepository.GetPagedProductsWithCount(IEnumerable`1& products, String groupIds, String 
searchValue, String languageId, String orderBy, String orderByDirection, Int32 pageSize, Int32 pageNumber, Boolean searchInAllFields, Nullable`1 shopType, Boolean includeOrphanedProducts)\r\n   
at Dynamicweb.Ecommerce.ProductCatalog.ViewModelFactory.CreateView(ProductListViewModelSettings settings, String groupId)\r\n   
at Dynamicweb.Ecommerce.WebAPI.Controllers.ProductsController.GetAll(SearchRequest search, ProductListViewModelSettings request)\r\n   
at lambda_method(Closure , Object , Object[] )\r\n   
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.b__9(Object instance, Object[] methodParameters)\r\n   
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   
at System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   
at System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   
at System.Web.Http.Dispatcher.HttpControllerDispatcher.d__1.MoveNext()"

After looking around we found this code under Dynamicweb.Ecommerce.Products.ProductRepository.GetPagedProductsWithCount()

Could the be a possible culprit? Maybe the pageNumber being zero or something along those lines?

I then decided to move on and try out the "/dwapi/Product/GetProductGroupList" endpoint. I got the following result

 

So I decided to try out the sample API provided by DW (https://doc.dynamicweb.com/dwapi/docs/index.html?url=/dwapi/api.json&layout=BaseLayout) but it seems like it has no products set up.

Do you have a sample webshop set up with products I could test against to see if it's my project/db that is causing the issue or if this is an issue with the new API?

Kind Regards,
Snævar

 

Code.png GetProductGroupList.PNG

Replies

 
Martin Vang
Martin Vang
Reply
This post has been marked as an answer

Hi Snævar,

Yep, that's a bug. Sorry about that. Bug 998: WebAPI Ecommerce/Products broken for groupsearch if no currentpage provided

You can work arround it, by providing the CurrentPage: 1 in a POST body. You probably want to use that post body anyway, to provide the currency ($ vs €) , country (VAT rate), language (translation) and shop (image patterns and other shop specific things) to use, depending upon your needs. Otherwise we use the Application defaults for these.

You can see this in action by typing this in the "Request body" on the TryItOut for the endpoint: {CurrentPage: 1}

Glad to hear you're tinkering arround with it.

BR

Martin

Votes for this answer: 1
 
Snaevar Petursson
Snaevar Petursson
Reply

Hej Martin 

Awesome! Thanks a bunch! 

By any chance do you know where I can see a list of all possible parameters for the endpoints in the API?
I originally tried this out with {PageNum: 1} without success. 


Kind Regards,

Snævar

 
Nicolai Pedersen
Reply
This post has been marked as an answer

In the docs!

Votes for this answer: 1
 
Nicolai Pedersen
Reply

Beautiful dump :-)

 
Snaevar Petursson
Snaevar Petursson
Reply

Thanks! This was very helpful :) 

 

You must be logged in to post in the forum