How to rename Item using REST API?

We need to rename Items using REST API from our another legacy system. We tried using -

curl -X PUT -k -H ‘Content-Type: application/json’ -H ‘Accept: application/json’ -i ‘https://xxxxxxxx.com/api/resource/Item/test-1’ --data ‘{“name”:“test-12345”}’

but we keep getting following error -

{“exc”:“["Traceback (most recent call last):\n File \"/opt/bench/erpnext/apps/frappe/frappe/app.py\", line 60, in application\n response = frappe.api.handle()\n File \"/opt/bench/erpnext/apps/frappe/frappe/api.py\", line 95, in handle\n \"data\": doc.save().as_dict()\n File \"/opt/bench/erpnext/apps/frappe/frappe/model/document.py\", line 259, in save\n return self._save(*args, **kwargs)\n File \"/opt/bench/erpnext/apps/frappe/frappe/model/document.py\", line 289, in save\n self.check_if_latest()\n File \"/opt/bench/erpnext/apps/frappe/frappe/model/document.py\", line 634, in check_if_latest\n frappe.throw((\"Record does not exist\"))\n File \"/opt/bench/erpnext/apps/frappe/frappe/init.py\", line 345, in throw\n msgprint(msg, raise_exception=exc, title=title, indicator=‘red’)\n File \"/opt/bench/erpnext/apps/frappe/frappe/init.py\", line 331, in msgprint\n _raise_exception()\n File \"/opt/bench/erpnext/apps/frappe/frappe/init.py\", line 304, in _raise_exception\n raise raise_exception(msg)\nValidationError: Record does not exist\n"]”,“_server_messages”:“["{\"message\": \"Record does not exist\", \"indicator\": \"red\"}"]”}

Can someone please help?

It clearly says there’s a validation error: Record does not exist

Are you sure the item with that name exists?

Absolutely sure… If we use GET request for the same item, it works like a charm!

Could you find the workaround?