Creating document by API

I’m trying create a simple Delivery Note document by frappe API, but:


         File "/home/ubuntu/frappe-bench/apps/frappe/frappe/", line 67, in application
        response = frappe.api.handle()
      File "/home/ubuntu/frappe-bench/apps/frappe/frappe/", line 119, in handle
        "data": frappe.get_doc(data).insert().as_dict()
      File "/home/ubuntu/frappe-bench/apps/frappe/frappe/", line 638, in get_doc
        return frappe.model.document.get_doc(*args, **kwargs)
      File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/", line 68, in get_doc
        return controller(*args, **kwargs)
      File "/home/ubuntu/frappe-bench/apps/erpnext/erpnext/stock/doctype/delivery_note/", line 25, in __init__
        super(DeliveryNote, self).__init__(*args, **kwargs)
      File "/home/ubuntu/frappe-bench/apps/erpnext/erpnext/controllers/", line 19, in __init__
        super(AccountsController, self).__init__(*args, **kwargs)
      File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/", line 112, in __init__
        super(Document, self).__init__(kwargs)
      File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/", line 54, in __init__
      File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/", line 77, in update
        self.set(key, value)
      File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/", line 124, in set
        self.extend(key, value)
      File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/", line 152, in extend
        self.append(key, v)
      File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/", line 138, in append
        value = self._init_child(value, key)
      File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/", line 164, in _init_child
        value["doctype"] = self.get_table_field_doctype(key)
      File "/home/ubuntu/frappe-bench/apps/frappe/frappe/model/", line 278, in get_table_field_doctype
        return self.meta.get_field(fieldname).options
    AttributeError: 'NoneType' object has no attribute 'options'


#Create a document by Frappe API                                                                                                                                       
url = ' Note'                                                                                                                
body = {                                                                                                                                                                 
    "naming_series": "DN-",                                                                                                                                          
    "posting_date": "12/12/2017",                                                                                                                                    
    "posting_time": "17:50:00",                                                                                                                                      
    "customer": "AGUA MEL FARMACIA DE MANIPULACAO LTDA ME",                                                                                                          
    "item": [       {                                                                                                                                                
                    "item_code": 1777,                                                                                                                         
                    "qty": 2                                                                                                                                         
rpost =, data=json.dumps(body))                                                                                                                         
print rpost.content                                                                                                                                                            

Can you help me find out what’s the problem?

Found it!

Some field names on body are wrong, like table name “item” , the right name is “items