Frappe Rest-API Update Issue

Hi! Im using V12 latest.

When i try to do a PUT using the API i get the following error:

Traceback (most recent call last):\n File \"/home/erpnext/frappe-bench/apps/frappe/frappe/app.py\", line 60, in application\n response = frappe.api.handle()\n File \"/home/erpnext/frappe-bench/apps/frappe/frappe/api.py\", line 84, in handle\n data = json.loads(frappe.local.form_dict.data)\n File \"/usr/lib/python3.5/json/__init__.py\", line 312, in loads\n s.__class__.__name__))\nTypeError: the JSON object must be str, not 'NoneType'\n

Any Idea why this happens?
Best Regards!

I found the issue.

In /apps/frappe/frappe/api.py line 84:

data = json.loads(frappe.local.form_dict.data)

This means the PUT-Request Body has to be a JSON with a field “data” which contains a json.

"{"data":"{\"parent_item_group\":\"adlehr\",\"adlehrid\":1,\"item_group_name\":\"Test1Gold\",\"name\":\"Test1Gold\"}"}"

Nested JSON is really useless. Isn’t it?

I think the line 84 should be replaced with

    if frappe.local.form_dict.data is None:
          data = json.loads(frappe.local.request.get_data())
    else:
          data = json.loads(frappe.local.form_dict.data)

Best Regards,
David

Hi,

I am getting the same issue. is it being fixed yet?
When updating Strings to the database, it is working. however, when passing a JSON object, it will crash, backend python will give an error when excute json.loads(frappe.local.request.get_data()).

Thanks