Since V7 has come out, I haven’t been able to use the PUT or DELETE functions from the REST API. I get the following error:
Traceback (most recent call last):
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/app.py”, line 58, in application
response = frappe.api.handle()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/api.py”, line 78, in handle
data = json.loads(frappe.local.form_dict.data)
File “/usr/lib/python2.7/json/init.py”, line 338, in loads
return _default_decoder.decode(s)
File “/usr/lib/python2.7/json/decoder.py”, line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
TypeError: expected string or buffer
This is using code that worked with v6. Also, I’m not even sure what JSON string needs to be decoded with DELETE.
I would normally agree with you, but I get the same error when sending a DELETE message, there is no JSON string to be decoded, so why would I get it then?
Traceback (most recent call last):
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/app.py”, line 58, in application
response = frappe.api.handle()
File “/home/ubuntu/frappe-bench/apps/frappe/frappe/api.py”, line 88, in handle
“data”: doc.save().as_dict()
AttributeError: ‘NoneType’ object has no attribute ‘as_dict’
With the new wrapper for save , nothing is returned. This means that the doc.save() call in line 88 of api.py has no return, and the as_dict() is called on nothing, causing the error.
I have created a pull request that should fix this: