4

I'm trying to get a tax class ID with only the tax rate value, all with the API. I found that I need a first request that returns me the tax rate ID :

/rest/all/V1/taxRates/search?searchCriteria[filterGroups][0][filters][0][field]=rate&searchCriteria[filterGroups][0][filters][0][value]=20

Then I want to request this API : /rest/all/V1/taxRules/search to get the tax class used by the tax rule (in my case we will only have one tax class, one tax rule for one tax rate so we know if a product has a defined tax class, which is its tax rate).

I search on the swagger and tried this :

/rest/all/V1/taxRules/search?searchCriteria[filterGroups][0][filters][0][field]=tax_rate_ids&searchCriteria[filterGroups][0][filters][0][value]=3&searchCriteria[filterGroups][0][filters][0][conditionType]=in

But I have this response : Internal Error. Details are available in Magento log file. Report ID: webapi-5bf536f4a45a5

I went to the logs and found this :

[2018-11-21 10:44:04] main.CRITICAL: Report ID: webapi-5bf536f4a45a5; Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tax_calculation_rate_id' in 'where clause', query was: SELECT COUNT(*) FROM `tax_calculation_rule` AS `main_table` WHERE ((`tax_calculation_rate_id` IN('3'))) {"exception":"[object] (Exception(code: 42): Report ID: webapi-5bf536f4a45a5; Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tax_calculation_rate_id' in 'where clause', query was: SELECT COUNT(*) FROM `tax_calculation_rule` AS `main_table` WHERE ((`tax_calculation_rate_id` IN('3'))) at /var/www/html/lib/internal/Magento/Framework/Webapi/ErrorProcessor.php:205, Zend_Db_Statement_Exception(code: 42): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tax_calculation_rate_id' in 'where clause', query was: SELECT COUNT(*) FROM `tax_calculation_rule` AS `main_table` WHERE ((`tax_calculation_rate_id` IN('3'))) at /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:235, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tax_calculation_rate_id' in 'where clause' at /var/www/html/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228)"} []

What did I do wrong ?

Thank you by advance

3

Please update your request like below.

rest/all/V1/taxRules/search?searchCriteria[filterGroups][0][filters][0][field]=tax_calculation_rate_id&searchCriteria[filterGroups][0][filters][0][value]=3&searchCriteria[filterGroups][0][filters][0][conditionType]=in

It'll work for you. Let me know if any further help needed.

  • Please give an upvote if it was helpful :) – Ramkishan Suthar Nov 21 '18 at 13:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.