Error 500 while submitting sales order - REST API

We’re using Rest APIs to create Sales Order, it’s on draft and I need to “submit”, if I tried to change the Sales Order status directly to “submit” it throws an error.

Body: form url encoded

action:Submit
doc:{
“name”: “SAL-ORD-2020-00020”,
“owner”: “[spru@ka.com”,
“creation”: “2020-10-12 19:07:19.236484”,
“modified”: “2020-10-12 19:07:19.236484”,
“modified_by”: “spru@ka.com”,
“parent”: null,
“parentfield”: null,
“parenttype”: null,
“idx”: 0,
“docstatus”: 0,
“title”: “4419691d718be8e80b3e73a7d2ea2524”,
“naming_series”: “SAL-ORD-.YYYY.-”,
“customer”: “4419691d718be8e80b3e73a7d2ea2524”,
“customer_name”: “4419691d718be8e80b3e73a7d2ea2524”,
“order_type”: “Sales”,
“skip_delivery_note”: 0,
“amended_from”: null,
“company”: “test”,
“transaction_date”: “2020-10-01”,
“delivery_date”: null,
“po_no”: “VLKR676721A9”,
“po_date”: null,
“tax_id”: null,
“customer_address”: null,
“address_display”: null,
“contact_person”: null,
“contact_display”: null,
“contact_phone”: null,
“contact_mobile”: null,
“contact_email”: null,
“company_address”: null,
“company_address_display”: null,
“shipping_address_name”: “”,
“shipping_address”: “UMMU HAFEERA 513- BAUDHDHALOKA , MAWATHA- COLOMBO 8 , COLOMBO 08”,
“customer_group”: “All Customer Groups”,
“territory”: “All Territories”,
“currency”: “LKR”,
“conversion_rate”: 1.0,
“selling_price_list”: “Standard Selling”,
“price_list_currency”: “LKR”,
“plc_conversion_rate”: 1.0,
“ignore_pricing_rule”: 0,
“set_warehouse”: null,
“scan_barcode”: null,
“total_qty”: 1.0,
“base_total”: 1780.0,
“base_net_total”: 1780.0,
“total_net_weight”: 0.0,
“total”: 1780.0,
“net_total”: 1780.0,
“tax_category”: “”,
“shipping_rule”: null,
“taxes_and_charges”: null,
“other_charges_calculation”: null,
“base_total_taxes_and_charges”: 0.0,
“total_taxes_and_charges”: 0.0,
“loyalty_points”: 0,
“loyalty_amount”: 0.0,
“coupon_code”: null,
“apply_discount_on”: “Grand Total”,
“base_discount_amount”: 0.0,
“additional_discount_percentage”: 0.0,
“discount_amount”: 0.0,
“base_grand_total”: 1780.0,
“base_rounding_adjustment”: 0.0,
“base_rounded_total”: 1780.0,
“base_in_words”: “LKR One Thousand, Seven Hundred And Eighty only.”,
“grand_total”: 1780.0,
“rounding_adjustment”: 0.0,
“rounded_total”: 1780.0,
“in_words”: “LKR One Thousand, Seven Hundred And Eighty only.”,
“advance_paid”: 0.0,
“payment_terms_template”: null,
“tc_name”: null,
“terms”: null,
“inter_company_order_reference”: null,
“project”: null,
“party_account_currency”: null,
“source”: null,
“campaign”: null,
“language”: “en”,
“letter_head”: null,
“select_print_heading”: null,
“group_same_items”: 0,
“status”: “Draft”,
“delivery_status”: “Not Delivered”,
“per_delivered”: 0.0,
“per_billed”: 0.0,
“billing_status”: “Not Billed”,
“sales_partner”: null,
“commission_rate”: 0.0,
“total_commission”: 0.0,
“from_date”: null,
“to_date”: null,
“auto_repeat”: null,
“doctype”: “Sales Order”,
“items”: [
{
“name”: “43775a0113”,
“owner”: “[spru@ka.com”,
“creation”: “2020-10-12 19:07:19.236484”,
“modified”: “2020-10-12 19:07:19.236484”,
“modified_by”: “[spru@ka.com”,
“parent”: “SAL-ORD-2020-00020”,
“parentfield”: “items”,
“parenttype”: “Sales Order”,
“idx”: 1,
“docstatus”: 0,
“item_code”: “flowers00T581”,
“customer_item_code”: null,
“ensure_delivery_based_on_produced_serial_no”: 0,
“delivery_date”: “2020-08-12”,
“item_name”: " Captured My Heart ",
“description”: “Captured My Heart”,
“item_group”: “FLOWER”,
“brand”: null,
“image”: “”,
“qty”: 1.0,
“stock_uom”: “Nos”,
“uom”: “Nos”,
“conversion_factor”: 1.0,
“stock_qty”: 1.0,
“price_list_rate”: 0.0,
“base_price_list_rate”: 0.0,
“margin_type”: “”,
“margin_rate_or_amount”: 0.0,
“rate_with_margin”: 0.0,
“discount_percentage”: 0.0,
“discount_amount”: 0.0,
“base_rate_with_margin”: 0.0,
“rate”: 1780.0,
“amount”: 1780.0,
“item_tax_template”: null,
“base_rate”: 1780.0,
“base_amount”: 1780.0,
“pricing_rules”: null,
“is_free_item”: 0,
“net_rate”: 1780.0,
“net_amount”: 1780.0,
“base_net_rate”: 1780.0,
“base_net_amount”: 1780.0,
“billed_amt”: 0.0,
“valuation_rate”: 0.0,
“gross_profit”: 1780.0,
“delivered_by_supplier”: 0,
“supplier”: null,
“weight_per_unit”: 0.0,
“total_weight”: 0.0,
“weight_uom”: null,
“warehouse”: “Head Office - KDCPL”,
“target_warehouse”: null,
“prevdoc_docname”: null,
“blanket_order”: null,
“blanket_order_rate”: 0.0,
“projected_qty”: 8.0,
“actual_qty”: 0.0,
“ordered_qty”: 0.0,
“planned_qty”: 0.0,
“work_order_qty”: 0.0,
“delivered_qty”: 0.0,
“produced_qty”: 0.0,
“returned_qty”: 0.0,
“additional_notes”: null,
“page_break”: 0,
“item_tax_rate”: “{}”,
“transaction_date”: “2020-10-01”,
“doctype”: “Sales Order Item”
}
],
“pricing_rules”: [],
“taxes”: [],
“packed_items”: [],
“payment_schedule”: [
{
“name”: “e5303a677c”,
“owner”: null,
“creation”: “2020-10-12 19:07:19.324479”,
“modified”: “2020-10-12 19:07:19.324479”,
“modified_by”: “[spru@ka.com”,
“parent”: “SAL-ORD-2020-00020”,
“parentfield”: “payment_schedule”,
“parenttype”: “Sales Order”,
“idx”: 1,
“docstatus”: 0,
“payment_term”: null,
“description”: null,
“due_date”: “2020-10-01”,
“invoice_portion”: 100.0,
“payment_amount”: 1780.0,
“mode_of_payment”: null,
“paid_amount”: 0,
“doctype”: “Payment Schedule”
}
],
“sales_team”: []
}

Response : Traceback (most recent call last):
File “/home/frappe-user/frappe-bench/apps/frappe/frappe/app.py”, line 64, in application
response = frappe.api.handle()
File “/home/frappe-user/frappe-bench/apps/frappe/frappe/api.py”, line 125, in handle
data = get_request_form_data()
File “/home/frappe-user/frappe-bench/apps/frappe/frappe/api.py”, line 143, in get_request_form_data
data = json.loads(frappe.safe_decode(frappe.local.request.get_data()))
File “/usr/lib/python3.6/json/init.py”, line 354, in loads
return _default_decoder.decode(s)
File “/usr/lib/python3.6/json/decoder.py”, line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File “/usr/lib/python3.6/json/decoder.py”, line 357, in raw_decode
raise JSONDecodeError(“Expecting value”, s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

The text editor for this forum provides a toolbar with buttons for correctly formatting code samples.

You are requesting that other members use their time to help you out, yet you do not use your time to learn those tools even enough to make it possible to read your question.

I have a lot of experience with the API and will make the effort to help you out, but only if I see you make the effort to format your question correctly.

For example, simply selecting your code and typing <ctrl>+<shift>+C, will produce:

{
    "naming_series": "001-002-.#########",
    "customer": "Diego Corral",
    "due_date": "2025-05-24",
    "taxes": [
        {
            "charge_type": "On Net Total",
            "account_head": "1.1.7.01.003 - Retencion IVA Terceros - LSSA",
            "rate": 12.0,
            "description": "Retencion IVA Terceros"
        }
    ],
    "items": [
        {
            "item_code": "BIODOX 2000 PPM 500ML",
            "qty": 1,
            "rate": 5000
        }
    ]
}

Change your docstatus value to 1 and change sales order status to “To Deliver and Bill”

Thanks