i'm using RestSharp in C# to connect with Magento2 REST API.
Everythings fine, except one simple thing:
lets say i've got a product, in its JSON-DATA there is a tax_class_id "4". Inside of this tax_class_id theres a tax rate of 19% integrated. How do i get the taxrate "19" from the tax_class_id "4"?
here's the call:
var response = new RestRequest("/rest/default/V1/products/SampleProduct",Method.GET);
response.RequestFormat = DataFormat.JSON;
response.AddHeader("Authorization","Bearer " + Token);
response.AddHeader("Accept","application/json");
here's the json-data from the response (all unnessary data like meta data etc. are cropped). I added some annotation "<<" for better understanding what i need
{
"items": [
{
"id": 1,
"sku": "SampleProduct",
"name": "a Simple Sample Product",
"attribute_set_id": 4,
"price": 4.99, << this is with tax, i need the taxrate to get the price without tax aswell
"status": 1,
"visibility": 4,
"type_id": "simple",
"created_at": "2017-10-04 12:11:03",
"updated_at": "2017-10-24 10:02:50",
"product_links": [
],
"tier_prices": [
],
"custom_attributes": [
{
"attribute_code": "tax_class_id",
"value": "4" << i've got the class_id, now i must have the taxrate. Its 19% but how do i get the value "19"
}
]
}
],
"total_count": 1
}
what can't be done:
- using PHP to do the Task
- changing some files to get it to work
what i have:
- the Magento 2.2 REST API
- C# as programming language to work with
- a Magento Shop with Access Token for REST API Requests, but no other physical access
- the product and all its data (except the taxrate ^^)
- the tax_class_id of the product
- the information that tax_class_id in *this* Shop for *this* product , id = 4 is 19% taxrate
- it must work with every other shop, every other tax_class_id, every other product as well, where e.g. id = 1 is 19% and id = 4 is like 7%
what i can use to get to it:
- the {TAXCLASSID} which is not the same as the {TAXRATEID}
what i need:
- the {TAXRATEID} to get the rate (e.g. 19 or 8.25)
Hope someone can help me with that task. Thanks in advantage.