Using API to add new Customer

Hi,
I read all infomation at: https://frappe.io/docs/user-guide/rest_api
And I have some problem when using API to add a new customer:

My URL Request: (POST method)
http://localhost/api/resource/Customer/

Body:
data={“name”: “Robert”, “customer_group”: “Commercial”, “customer_type”: “Company”, “territory”: “Vietnam”}

And this is my result:
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 52, in application response = frappe.api.handle() File “/home/frappe/frappe-bench/apps/frappe/frappe/api.py”, line 97, 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

Can you help me using or customize to fix this API ?
Thank you so much !

I think the body should be directly the JSON without data= ?

Hi rmehta,
I have tried with:
{ “data”: {“name”: “Robert”, “customer_group”: “Commercial”, “customer_type”: “Company”, “territory”: “Vietnam”} }
and:
{“name”: “Robert”, “customer_group”: “Commercial”, “customer_type”: “Company”, “territory”: “Vietnam”}

But… I still receive error.

see frappe-client/frappeclient.py at master · frappe/frappe-client · GitHub

Thank for your help. Issue fixed.