'Magento 2.4 API, POST product custom_attributes

I need to add/update products using the REST API. I cannot figure how to add a custom_attributes, knowing only the value/label of the attribute and not the ID (attribute of type 'dropdown' or 'selectable')

POST /rest/all/V1/products

{
    "product": {
        "sku": "D119",
        "custom_attributes": [{
            "attribute_code": "year",
            "value": "2015"
        }]
    }
}

Upper code works fine if I just put in the ID in the value field. But a sourcing system wouldnt know the id's....

Side note: The M2 backend import function is capable of importing value/label of the attribute? How come?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source