Just came across this when looking in to something myself. Did you get to the bottom of the problem in the end and what was the solution?
Topic summary
Issue: Setting Harmonized System (HS) code and Country of Origin during product creation via REST by adding variant metafields didn’t reflect correctly in the Shopify Admin. HS code metafield appeared in data, but the Admin HS field showed blank; entering HS in Admin overwrote the metafield value.
Key detail: HS code (Harmonized System code) and Country of Origin are not stored on Product or Variant metafields. They are properties of the InventoryItem resource.
Cause of mismatch: Writing these values as variant metafields doesn’t populate the Admin’s HS/Country fields, which read from InventoryItem. Hence the apparent desync.
Resolution/Action:
- After creating products/variants, retrieve each variant’s inventory_item_id.
- Update the InventoryItem via Admin REST PUT to set harmonized_system_code and country_code_of_origin (and province codes if needed): PUT /admin/api/2024-10/inventory_items/{inventory_item_id}.json.
- Reference: Shopify InventoryItem docs and changelog indicating HS/country/province are on InventoryItem.
Outcome: Problem resolved by updating InventoryItem fields directly. Discussion closed with a clear solution.