vc-platform
vc-platform copied to clipboard
Deleting products through REST API fails
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).
- Could you explain, what version of platform/modules do you mean?
- Write endpoint you call exactly. Thanks!
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
actually. this is works well only by Ids. can't delete by SKU. look at
lets try to delete via swagger http://localhost/virto/docs/ui/index#/Catalog%20module/CatalogModuleProducts_Delete
This is really unfortunate/bad. Everything we do is by SKUs. We never actually touch the IDs if not absolutely necessary.
Recently we added endpoint to delete entries by the search criteria - POST "api/catalog/listentries/delete": https://github.com/VirtoCommerce/vc-module-catalog/commit/0345cb412812b0bab868a82e6a3548fcabedc02e 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.
What if we just delete the records from the database, that would work but what about side effects?