REST API POST for Customer and Sales Invoice DocType Challange

I’m trying to integrate our own POS and some More features with ERPNEXT and having challenge with following list.

  1. Rest API unable to post records for sales and Customer. i tried the following URL. where as GET request is working fine. i’m testing it with POSTMAN app.{“customer_name”: “Adnan”,“customer_group”:“Commercial”,“customer_type”: “Company”,“territory”: “US”}

  1. how to create Customer with Contact through API
  2. where i can find the list of Whitelist Methods which we can call through API like “Login…etc”
  3. any sample URL to create invoice through API.

before using API we were thinking to write a SP to post sale invoice directly to DB but that can create some unknown challenges and finally we decided to go with API. any support will be highly appreciated.



Refer this page for Rest API - Rest API

You can create a document by sending a POST request to the URL

e.g. for creating customer



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

Thanks @Sangram
i tried the above data as it is but i’m getting the internal server error. find the below image. but i’m able to fetch the data. and yes i got most of the help from rest api document.

Instead of raw pass it from form-data

it’s not working on my side even i tried same parameters…

there shouldn’t be any issue…

Can share full traceback/ Response.

sorry i got it…let me see if i can fix it

Thanks i got it working.

is their any example where we can insert customer along with contact together?
also where i can find the list of white list methods?

really appreciate your efforts.


you have to write separate API for both Customer and Contact.

Check for more details

hi @Sangram
hope you are doing good. i’m facing a small challenge with sales invoice through API with Payment information. and i’m getting the above error with V8.

below is the string i’m passing.

“cash_bank_account”:“Cash - CP”,
“against_income_account”:“Sales - CP”,
“mode_of_payment”:" Cash",
“customer_name”:“Mehdi Hassan”,
“company”:“Test Company”,
“customer”:“Mehdi Hassan”,
“is_opening”:" No",
“debit_to”:“Debtors - CP”,
“remarks”:" POS - 100306",
“posting_date”:" 2017-05-08",
“selling_price_list”:“PIP Selling”,
“items”:“FROBEN SR 200MG CAP”,
“cost_center”:“Branch - CP”,
“warehouse”:“Branch - CP”,
“pricing_rule”:“7% Discount “,
“item_code”:“FROBEN SR 200MG CAP”,
“parenttype”:” Sales Invoice”,
“mode_of_payment”:" Cash",
“account”:“Cash - CP”

if i remove the payment section from above data it’s working fine.

please have a look if you have time to see where i’m doing mistake.

Thanks in Advance.

Need Urgent help if someone tested Sales invoice with V8 REST API


It is python error, have to look can’t multiply sequence by non-int of type ‘float’

Might be you are giving wrong inputs in the payment section.

Do it without adding payment section and do it manually so will get the issue. Where it comes from.

Hello , @adnan

i am getting the same problem trying to create customer through api ,
can you tell me how you got this solved ?

i am passing data according to above.

this is the string i am passing in value :

{"customer_name":"test_customer","customer_group":"All Customer Groups","territory":"All Territories","customer_type":"Company","mobile_no":“546546546”}

its giving me Json error

File “/usr/lib/python2.7/json/”, line 366, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python2.7/json/”, line 384, in raw_decode
raise ValueError(“No JSON object could be decoded”)
ValueError: No JSON object could be decoded
Status: 500

any help is appreciated

Check the double quotes “546546546”

1 Like

copy your value of JSON and try in the following website.

it’ll tell you where the problem is in your json.

in Above json, “546546546” these are not double quotes. correct them.


Thanks a Ton @adnan , @schilgod ,
could you please guide me to create a sales invoice as well ,
i just want to create a pos invoice with minimum details ,

here is the string i pass
{"is_pos":"1","submit_on_creation":"1","customer":"test","update_stock":"1","territory":"All","is_opening":" No","currency":"KWD","debit_to":"Debtors - SJ","items":[{"item_code":"test item-06D","qty":"15","rate":"5"}],"payments":[{"mode_of_payment":" Cash","amount":"250"}]}

the json checks out from the validation on the site

but it gives me an error -

File “/home/taher/frappe-bench/apps/frappe/frappe/model/”, line 465, in get_invalid_links
setattr(self, df.fieldname,
AttributeError: ‘NoneType’ object has no attribute ‘name’
Status: 500

thank you in advance .

Please POST full Error.

This error Means you are using wrong Value for a list Field. or mandatory parameter is missing

i think the issue is with the payments ,

when i pass params as :
{"customer":"test_customer123","submit_on_creation":"1","is_pos":"1","update_stock":"1","items":[{"item_code":"test item-06D","qty":"15","rate":"5"},{"item_code":"test item 6d box","qty":"1","rate":"5"}]}

It works absolutely fine , though still invoice does not get submitted ,
but when i try to pass the payments as
{"customer":"test_customer123","submit_on_creation":"1","is_pos":"1","update_stock":"1","items":[{"item_code":"test item-06D","qty":"15","rate":"5"},{"item_code":"test item 6d box","qty":"1","rate":"5"}],"payments":[{"mode_of_payment":" Cash","amount":"250"}]}

its giving me below error :

Server Error
Traceback (most recent call last):
File “/home/taher/frappe-bench/apps/frappe/frappe/”, line 67, in application
response = frappe.api.handle()
File “/home/taher/frappe-bench/apps/frappe/frappe/”, line 119, in handle
“data”: frappe.get_doc(data).insert().as_dict()
File “/home/taher/frappe-bench/apps/frappe/frappe/model/”, line 217, in insert
File “/home/taher/frappe-bench/apps/frappe/frappe/model/”, line 717, in _validate_links
result = d.get_invalid_links(is_submittable=self.meta.is_submittable)
File “/home/taher/frappe-bench/apps/frappe/frappe/model/”, line 465, in get_invalid_links
setattr(self, df.fieldname,
AttributeError: ‘NoneType’ object has no attribute ‘name’
Status: 500

all the spelling and mandatory fields are there , still i am not sure why payments is causing the issue .

yes you are missing Mandatory Parameters from Payment.


try with these parameters.

and Amount should not be in Double quotes