Create BOM using REST API

I am trying to POC integrate our in house PLM with ERPNext using ERPNext’s REST API. Till now I was able to

  1. Login

  2. Get its cookie information

  3. Get list if Items

  4. Insert Item

But when I am trying to create a BOM I am not to find the proper API in ERPNext or Frappe framework code.

Can some one please point me to some link or provide a sample code?


Please refer

1 Like

Thanks for the reply I had gone through that link and was able to login and create item using the API. I am stuck at creating BOM. I checked the code and did not find any method or API which will help me in creating the BOM and BOM Item.

Does nobody has used API to create a BOM in ERPNext?

I have used many different ways to create a BOM

But were a failure majorly I am getting Invalid method response.

You need to call POST http://localhost:8080/api/resource/Bill of Material

Thanks for the reply. I tried it but the URL is not working. And when I tried with
http://localhost:8080/api/resource/bom/bill_of_material it gives 200 OK message but the BOM is not created.

My input data is
“rm_cost_as_per”: “Valuation Rate”}

but if I remove the bom string from the URL I am getting 500 internal server error.


check for error traceback in terminal and share the traceback

Following is one of the trace back. For this the URL was http://localhost:8080/api/resource/bill_of_material

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 60, in application
response = frappe.api.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 120, in handle
“data”: frappe.get_doc(data).insert().as_dict()
File “/home/frappe/frappe-bench/apps/frappe/frappe/”, line 596, in get_doc
return frappe.model.document.get_doc(arg1, arg2)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 48, in get_doc
controller = get_controller(doctype)
File “/home/frappe/frappe-bench/apps/frappe/frappe/model/”, line 34, in get_controller
module = load_doctype_module(doctype, module_name)
File “/home/frappe/frappe-bench/apps/frappe/frappe/modules/”, line 173, in load_doctype_module
raise ImportError, ‘Module import failed for {0} ({1})’.format(doctype, module_name)
ImportError: Module import failed for bill_of_material (frappe.core.doctype.bill_of_material.bill_of_material)

bill_of_material is not a valid doctype name to create Bill of Material use the doctype name as BOM

e.g. http://localhost:8080/api/resource/BOM

When I call it using that URL I get 400 bad request and there is no trace back only
“Server Error No Message”

And If add one more /bom to the url some times it gives 200 OK message other time 400 Bad request. And when it gives 200 message it does not create any BOM which is visible in the ERPnext Web UI

Thanks @makarand_b after restarting the VM I was able to create the BOM using the example URL provided by you. Earlier I tried with lowercase “bom” in the URL and it had not worked.

In the help document we should have a list of all the APIs exposed by ERPnext.


All the installed app doctype are accessible to the REST API although it will first check the user permissions first.

e.g. if user login using api then before create/update system will check if the user has the permissions to create, read or update.


That is there but in the case of BOM the API is case sensitive and if you check the code every where it is lowercase in this case the end user will be confused and they will search the discussion forums for the answers. That is why I was telling to have a document with all the API listed. Even the site does not provide WSDL list of the API.