Magento 2 – Setting Product URL Key with REST API

apimagento2product-urlsresturl-key

Is it possible? I see no mention of a url_key in the Swagger docs.

I have a large database of product I need to import, and the names (which seem to determine the url) are not unique.

Best Answer

Although Swagger doesn't specify "url_key", you can add this attribute value by the following method:

{
  "product": {
    ...
    "customAttributes": [
      {
        "attributeCode": "url_key",
        "value": "<your_value>"
      }
    ]
  }
}

Note: Next time, you can use GET to know the product JSON structure first. Then any customized attributes can be created according to the JSON structure.

Related Topic