REST API Submitting Sales Invoice Submission with payment Challange in v8

with Version 8, i’m trying to submit the sales invoice with payment and i’m posting in following format.
{
“cash_bank_account”:“Cash - CP”,
“is_pos”:“1”,
“submit_on_creation”:“1”,
“against_income_account”:“Sales - CP”,
“party_account_currency”:“USD”,
“owner”:“administrator”,
“price_list_currency”:“USD”,
“mode_of_payment”:" Cash",
“customer_name”:“Mehdi Hassan”,
“update_stock”:“1”,
“company”:“Test Company”,
“customer”:“Mehdi Hassan”,
“territory”:“All”,
“is_opening”:" No",
“customer_group”:“Individual”,
“naming_series”:“MTS-”,
“currency”:“USD”,
“debit_to”:“Debtors - CP”,
“remarks”:" POS - 100306",
“posting_date”:" 2017-05-08",
“selling_price_list”:“PIP Selling”,
“discount_amount”:“”,
“apply_discount_on”:“”,
“items”:“FROBEN SR 200MG CAP”,
“items”:[
{
“cost_center”:“Branch - CP”,
“qty”:“15”,
“warehouse”:“Branch - CP”,
“pricing_rule”:“7% Discount “,
“owner”:“administrator”,
“item_code”:“FROBEN SR 200MG CAP”,
“parenttype”:” Sales Invoice”,
“parentfield”:“items”
}
],
“payments”:[
{
“mode_of_payment”:" Cash",
“amount”:“282.6”,
“account”:“Cash - CP”
}
]
}
and i’m getting the following error.

i searched through the forms and found that same issue was appeared in V7 and was fixed in sep 2016.

any help will be appreciated.

Regards,
Adnan

any one who is using V8 API for Sales Invoices?

i find the solution and the mistake i was doing. the above example is working now

I believe the issue is related to this line… you’ve entered this as a string when it should be a number (no quotes).

Thanks Ben.

You are right. i was sending these parameters as string. even other Boolean parameters.

Thanks for your reply.

Working sample data to create ‘Sales Invoice’ through ERPNext Rest API

$salesInvoiceData = [ "docstatus" => 1, "customer" => "Test Customer API", "due_date" => date('Y-m-d'), "is_pos" => 1, "update_stock" => 1, "items" => [ [ "item_code" => "SUNSCN_0001", "qty" => 1, "rate" => 950 ], [ "item_code" => "PUPBRA", "qty" => 1, "rate" => 850 ] ], "payments" => [ [ "mode_of_payment" => "Cash", "amount" => 1800, "account" => "Cash - ZT", ] ] ];