An API I am using now sends data as an array of JSON objects. I am trying to receive this POST request with Frappe/ERPNext:
POST /your_url HTTP/1.1
Content-Type: application/json; charset=utf-8
[
{
"type" : "message-received",
"time" : "2020-01-12T11:11:17Z",
"description" : "Incoming message received",
"message" : "Test!"
}
]
My test code is simply:
@frappe.whitelist(allow_guest=True)
def postTest():
data = json.loads(frappe.request.data)
The error I am receiving in frappe.log is:
Request Error
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 52, in application
init_request(request)
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 115, in init_request
make_form_dict(request)
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 130, in make_form_dict
for k, v in iteritems(args) })
File “/home/frappe/frappe-bench/env/lib/python3.6/site-packages/six.py”, line 589, in iteritems
return iter(d.items(**kw))
AttributeError: ‘list’ object has no attribute ‘items’
Is there any way for me to properly receive these arrays?
I am using erpnext 12.5.2 and frappe 12.3.0 with python 3.6.9