Try ERPNext Try Frappe Cloud Buy Support Partners Foundation

API Error in v12 when posting invoice

I am getting below error when posting invoice through API. The same was working with v11

Traceback (most recent call last):
File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 60, in application
response = frappe.api.handle()
File "/home/frappe/frappe-bench/apps/frappe/frappe/api.py", line 116, in handle
data = json.loads(frappe.local.form_dict.data)
File "/usr/lib/python3.6/json/__init__.py", line 348, in loads
'not {!r}'.format(s.__class__.__name__))
TypeError: the JSON object must be str, bytes or bytearray, not 'NoneType'

Can anyone pls help me on this?

i am deeply dependent on API to use ERPNext

seems you are not sending json properly. Can you post the JSON here?

I have an instance of ERPNext v11 on another AWS instance. If i fire the same JSON to v11 using Postman, it is working.

Tried with this simple JSON to create customer, same issue

{
"customer_group": "Commercial",
"territory": "India",
"customer_type": "Company",
"customer_name": "Sangram Patil"
}

Can you please help me?

This seems a bug in v12.
I installed v11 with the easy install --version flag. Things are fine now.

A similar report here TypeError: the JSON object must be str, bytes or bytearray, not 'dict'

This howto may help you to debug the problem Debugging in ERPNext

I tried that too. I the other post, ‘dict’ is received.
But in my case ‘NoneType’ is received to the function. That means data is not received at all.

@Vinod_Nadar. have you managed to fix this issue? i am also facing the same issue

@Vinod_Nadar

This worked for me in V12:

curl -LX POST 'https://erp.yourpublic.work/api/resource/Sales%20Invoice' \
--header 'Authorization: token {{Key}}:{{Secret}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name": "001-002-000002015",
    "naming_series": "001-002-.#########",
    "customer": "Carlos Lopez",
    "posting_date": "2020-05-26",
    "posting_time": "16:58:41",
    "due_date": "2020-08-26",
    "items": [
        {
            "item_code": "ARCM-30ml",
            "qty": 1,
            "rate": 1
        }
    ]
}'