During API Call I keep getting [AttributeError: 'NoneType' object has no attribute 'options']

Hello People!

I am trying to access the self-hosted ERPNext instance through Frappe REST API. The instance is hosted in a Debian system running at Google Cloud compute engine.


  • Frappe v12.16.3
  • ERPNext v12.19.0

About 24 hours ago, I was able to do a normal request to the API. I did create leads by posting requests from Postman with valid authentication and body as JSON.

Following are my Postman configurations for current and most recent requests that fail. For the API URL I’m using, please notice that the Domain/IP is right, I double-checked that.

Well, I can not share the base64 authentication string here. But I’m sure that it’s accurate. To confirm, I doubled checked the API Secret and Key for my users’ account and generate the base64 script with multiple sources, I got the same string generated from all sources. I put this in the header section of the request keeping the format Authentication as key and Basic <base64 string> as value. Here is the screenshot.

The last, but equally important thing is the Body. The radio button next to Raw is selected also from the drop-down list JSON is selected. As the lead doctype has only one mandatory field which is lead_name. I’m sending lead_name and its value in the JSON body. Here is the screenshot


With these settings already configured, when I send a request, I get the following error in response. The status code is 500 Internal Server Error. Here is a screenshot from the saved error response

I traced back the error all the way from /home/frappe/frappe-bench/apps/frappe/frappe/app.py to return self.meta.get_field(fieldname).options\\nAttributeError: 'NoneType' object has no attribute 'options'. I do not found any code file missing, all the .py documents are untouched from the time of ERPNext Installation.

I found these issue (1, 2, 3, 4) on GitHub and Forum but couldn’t find any solution relevant to my usecase.

NOTE: I was able to reproduce the same error while accessing the v13.3.0 Instance API, which is a completely different machine hosted on the Google Cloud. Also, I wrote this python script that does the same thing but I’m unable to create an entry in the system.

import base64
import requests
import webbrowser
from json import dumps

url = "http://myerpdomain/api/resource/Lead"
key_secret_byte = "<API Key>:<API Secret>".encode('ascii')
auth = "Basic %s" % base64.b64encode(key_secret_byte)

headers = {
    'Authorization': auth

body = {
            "lead_name": "Aamir Khan M"

   #Convert from dectionary to json
    body = dumps(body, indent=4)


    response = requests.request("POST", url, headers=headers, json=body)
    if response.status_code == 200:
        print("Status Code: ", response.status_code)
        print("Something is not right.")

except Exception as err:

        print("Error Occured: {}".format(err))

Please, help me with finding a solution to this problem, we can not proceed without resolving this issue.

Thank you. Stay safe and blessed.

EDIT Corrected semantics and other mistakes. Added code.

I think the JSON being sent here wrong. This looks more like the response that is generated on success.

What you’re sending is the response data, while sending it should look like:

-d {
       "lead_name": "Aamir Khan M"

Additionally, suggest referring to: