Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting products through REST API fails #1829

Open
brgrz opened this issue Apr 12, 2020 · 7 comments
Open

Deleting products through REST API fails #1829

brgrz opened this issue Apr 12, 2020 · 7 comments

Comments

@brgrz
Copy link

brgrz commented Apr 12, 2020

I'm trying to remove some products through the REST API but I'm running into issue/exception. I actually only tried with one product SKU but I would like to add multiple later and perform batch delete.

  "message": "An error has occurred.",
  "exceptionMessage": "The parameterized query '(@p0 nvarchar(6),@p1 nvarchar(4000))\r\n                    IF EXI' expects the parameter '@p1', which was not supplied.",
  "exceptionType": "System.Data.SqlClient.SqlException",
  "stackTrace": "   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)\r\n   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.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)\r\n   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)\r\n   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)\r\n   at 

Is this something on my end or is it an issue with VC platform? I'm running pretty novel version of VC platform (think it was updated in Feb or Mar).

@akak1977
Copy link
Contributor

  1. Could you explain, what version of platform/modules do you mean?
  2. Write endpoint you call exactly.
    Thanks!

@brgrz
Copy link
Author

brgrz commented Apr 14, 2020

Hey, I'm running the DELETE products api on the Catalog module.

/api/catalog/products
Deletes the specified items by id.

Platform version is 2.13.50, all modules are up-to-date.

The exception above is now gone, apparently it was related to having an empty ID textbox in Swaggers "try it out" feature.

There is a new issue now, SKUs are not being deleted, no exception, API returns 204 No Content.

Request is
DELETE https://localhost/virto/api/catalog/products?ids=800224

@kostyrin
Copy link
Contributor

actually. this is works well only by Ids. can't delete by SKU. look at
image

@kostyrin
Copy link
Contributor

@brgrz
Copy link
Author

brgrz commented Apr 16, 2020

This is really unfortunate/bad. Everything we do is by SKUs. We never actually touch the IDs if not absolutely necessary.

@yecli
Copy link
Contributor

yecli commented Apr 16, 2020

Recently we added endpoint to delete entries by the search criteria - POST "api/catalog/listentries/delete":
VirtoCommerce/vc-module-catalog@0345cb4
It is available in 2.23.34 catalog module release.

It has Code in the search criteria + probably using Terms you can find multiple products by SKUs.

Caution: Be careful when deleting products by the search results. E.g. products have their variations in the "code" property in index. So search results may be wider than just one item with this SKU. I would advise deleting based on the SearchCriteria.ObjectIds to avoid possible ambiguities.
image

@brgrz
Copy link
Author

brgrz commented Apr 17, 2020

What if we just delete the records from the database, that would work but what about side effects?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants