Error creating a Sales Order using REST API

I’m trying to generate a Sales Order using a POST request but a ‘Server Error’ occurs. The permissions are fine and I’m supplying all the mandatory fields but the error persists.

This is my POST request

http://MyServerURL/api/resource/Customer?data={"naming_series":"SO- 
","customer":"Packages 
Mall","order_type":"Sales","company":"Company","transaction_date":"09-12- 
2018","currency":"PKR","conversion_rate":1,"selling_price_list":"Standard 
Selling","plc_conversion_rate":1,"items":[{"item_code":"JAM002","item_name":"Mango 
Jam","description":"Hello World","qty":2,"uom":"Nos","conversion_factor":1}],"sales_team": 
[{"sales_person":"Hamza Khan"}],"status":"Draft"}

The error details are as follows:

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 67, in application
response = frappe.api.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/api.py”, line 119, in handle
“data”: frappe.get_doc(data).insert().as_dict()
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 638, in get_doc
return frappe.model.document.get_doc(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 68, in get_doc
return controller(*args, **kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/document.py”, line 112, in init
super(Document, self).init(kwargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 54, in init
self.update(d)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 77, in update
self.set(key, value)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 124, in set
self.extend(key, value)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 152, in extend
self.append(key, v)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 138, in append
value = self._init_child(value, key)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 164, in _init_child
value[“doctype”] = self.get_table_field_doctype(key)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/base_document.py”, line 278, in get_table_field_doctype
return self.meta.get_field(fieldname).options
AttributeError: ‘NoneType’ object has no attribute ‘options’

Hi welcome to ERPNext,

Is each fieldname is spelled correctly?

That’s just my guess from a search on AttributeError: ‘NoneType’ object has no attribute ‘options’

that turns up this fix for eg Creating document by API

2 Likes

Yeah I misspelled one of the field name. Issue is solved now.
Thanks!