Frappeclient.submit() returns HTML and not success

Hi guys,

let me know if I set the category wrong here.

First of all, my objective is to write a frappeclient script to create records in ERPNext and submit it by using GitHub - frappe/frappe-client: Python library to use Frappe API

I am able to create records(in my case purchase order). Unfortunately, frappeclient.submit() returns response of some sort of data in HTML and an exception. The newly created records remains the status as it new created which means the frappeclient.submit() is not succeed.

Therefore, I am not sure if I am using the wrong function called to do submit or any wrong to the input.

Sample of the returning HTML

<!DOCTYPE html>
<!-- Built on Frappe. https://frappeframework.com/ -->
<html lang="en">
<head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <meta name="generator" content="frappe">


                <meta name="title" content="Server Error"><meta name="language" content="en"><meta property="og:type" content="article"><meta property="og:title" content="Server Error"><meta name="twitter:title" content="Server Error"><meta name="twitter:card" content="summary">


        <title>Server Error</title>


        <link
                rel="shortcut icon"
                href="/private/files/Spectacular Years Limited.jpg"
                type="image/x-icon"
        >


        <link rel="canonical" href="http://erpnext-128242-0.cloudclusters.net/message"><link type="text/css" rel="stylesheet" href="/assets/frappe/dist/css/website.bundle.YIFXBCFU.css">
                <link type="text/css" rel="stylesheet" href="/assets/erpnext/dist/css/erpnext-web.bundle.26Y2ZMU7.css">


                <script>
                window.frappe = {};
                frappe.ready_events = [];
                frappe.ready = function(fn) {
                        frappe.ready_events.push(fn);
                }
                window.dev_server = 0;
                window.socketio_port = 9000;
                window.show_language_picker = false;
        </script>
</head>
<body frappe-session-status="logged-in" data-path="message" class="">
        <svg id="frappe-symbols" aria-hidden="true" style="position: absolute; width: 0; height: 0; overflow: hidden;" class="d-block" xmlns="http://www.w3.org/2000/svg">
        <symbol viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" id="icon-up-line">
                <path d="M13 10.5L8 5.5L3 10.5" stroke="var(--icon-stroke)" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg" id="icon-small-up">
                <path d="M9.5 7.75L6 4.25L2.5 7.75" stroke="var(--icon-stroke)" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" id="icon-down">
                <path d="M3 5.5l5 5 5-5" stroke="var(--icon-stroke)" stroke-linecap="round" stroke-linejoin="round"></path>
        </symbol>

        <symbol viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg" id="icon-small-down">
                <path d="M2.625 4.375L6 7.75l3.375-3.375" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path>
        </symbol>

        <symbol viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg" id="icon-right">
                <path d="M4.25 9.5L7.75 6L4.25 2.5" stroke="var(--icon-stroke)" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg" id="icon-left">
                <path d="M7.5 9.5L4 6l3.5-3.5" stroke="var(--icon-stroke)" stroke-linecap="round" stroke-linejoin="round"></path>
        </symbol>

        <symbol viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-up-arrow">
                <path d="M6.03335 3.23495L6.03169 9.23495" stroke="var(--icon-stroke)" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M3.36665 5.43497L6.03332 2.7683L8.69998 5.43497" stroke="var(--icon-stroke)" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-down-arrow">
                <path d="M6.03328 8.7683L6.03494 2.7683" stroke="var(--icon-stroke)" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M8.69998 6.56828L6.03331 9.23495L3.36665 6.56828" stroke="var(--icon-stroke)" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-arrow-left"  stroke-width="1.2">
                <path d="M1.7001 6.00022L10.7001 6.00272" stroke="var(--icon-stroke)" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M3.99995 9L1 6L3.99995 3" stroke="var(--icon-stroke)" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-arrow-right" stroke-width="1.2">
                <path d="M10 6.00223L1 5.99973" stroke="var(--icon-stroke)" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M7.70015 3.00244L10.7001 6.00244L7.70015 9.00244" stroke="var(--icon-stroke)" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-sidebar-collapse">
                <path d="M12 6L6 12L12 18" stroke="var(--icon-stroke)"  stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M18 6L12 12L18 18" stroke="var(--icon-stroke)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-sidebar-expand">
                <path d="M12 18L18 12L12 6" stroke="var(--icon-stroke)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M6 18L12 12L6 6" stroke="var(--icon-stroke)" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-change">
                <path d="M13.2818 11.5388H2.59961" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M5.06069 14L2.59961 11.539L5.06069 9.07788" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M2.91406 4.46118H12.9679" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M10.5059 2L12.9669 4.46108L10.5059 6.92217" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" id="icon-sort">
                <path d="M9.5 10.5l2 2 2-2m-2 2v-9m-5 2l-2-2-2 2m2-2v9" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path>
        </symbol>

        <symbol viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg" id="icon-select">
                <path d="M4.5 3.636L6.136 2l1.637 1.636M4.5 8.364L6.136 10l1.637-1.636" stroke-linecap="round" stroke-linejoin="round"></path>        
        </symbol>

        <symbol viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-arrow-up-right">
                <path d="M2.5 9.5L9.5 2.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M9.50002 8V2.5H4.00002" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-arrow-down-left">
                <path d="M9.5 2.5L2.5 9.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M2.49999 4L2.49998 9.5L7.99998 9.5" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg" id="icon-expand">
                <path d="M10 2L6.844 5.158M7.053 2h2.948v2.948M5.158 6.842L2 10m0-2.947V10h2.947" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path>
        </symbol>

        <symbol id="icon-collapse" viewBox="0 0 32 32">
                <path stroke-linejoin="round" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2.6667" d="M18.246 13.754l8.421-8.421"></path>
                <path stroke-linejoin="round" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2.6667" d="M5.333 26.667l8.421-8.421"></path>
                <path stroke-linejoin="round" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2.6667" d="M26.106 13.754h-7.86v-7.86"></path>
                <path stroke-linejoin="round" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2.6667" d="M13.754 26.105v-7.86h-7.86"></path>
        </symbol>

        <symbol viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-expand-alt">
                <path d="M11.233 6.00021L7 6.00021" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M9.14874 3.91626L11.2328 6.00037L9.14874 8.08447" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M4.99998 6.00023L0.767046 6.00023" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M2.85092 3.91578L0.766818 5.99988L2.85092 8.08398" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-shrink">
                <path d="M6.76703 6.00006H11.233" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/> 
                <path d="M8.85114 8.08422L6.76703 6.00012L8.85114 3.91602" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M0.767031 6.00006H5.23297" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
                <path d="M3.14886 8.08422L5.23297 6.00012L3.14886 3.91602" stroke="var(--icon-stroke)" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg" fill="#112B42" id="icon-up">
                <path d="M3 5h6L6 2 3 5z"></path>
                <path opacity=".5" d="M6 10l3-3H3l3 3z"></path>
        </symbol>

        <symbol viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg" id="icon-both">
                <path fill-rule="evenodd" clip-rule="evenodd" d="M6 2l3 3H3l3-3zm3 5l-3 3-3-3h6z" fill="#112B42"></path>
        </symbol>

        <symbol viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" id="icon-small-add">
                <path d="M8 4v8M4 8h8" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path>
        </symbol>

        <symbol viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" id="icon-add">
                <path d="M8 3v10M3 8h10" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"></path>
        </symbol>

        <symbol viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" id="icon-close">
                <path fill-rule="evenodd" clip-rule="evenodd" d="M4.146 11.217a.5.5 0 1 0 .708.708l3.182-3.182 3.181 3.182a.5.5 0 1 0 .708-.708l-3.182-3.18 3.182-3.182a.5.5 0 1 0-.708-.708l-3.18 3.181-3.183-3.182a.5.5 0 0 0-.708.708l3.182 3.182-3.182 3.181z" stroke-width="0"></path>
        </symbol>

        <symbol viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" id="icon-close-alt">
                <path fill-rule="evenodd" clip-rule="evenodd" d="M3.78033 2.71967C3.48744 2.42678 3.01257 2.42678 2.71967 2.71967C2.42678 3.01256 2.42678 3.48744 2.71967 3.78033L6.94054 8.00119L2.71967 12.2221C2.42678 12.515 2.42678 12.9898 2.71967 13.2827C3.01257 13.5756 3.48744 13.5756 3.78033 13.2827L8.0012 9.06185L12.222 13.2826C12.5149 13.5755 12.9897 13.5755 13.2826 13.2826C13.5755 12.9897 13.5755 12.5148 13.2826 12.222L9.06186 8.00119L13.2826 3.78044C13.5755 3.48755 13.5755 3.01267 13.2826 2.71978C12.9897 2.42688 12.5149 2.42689 12.222 2.71978L8.0012 6.94054L3.78033 2.71967Z" stroke="none" fill="var(--icon-stroke)"/>
        </symbol>

        <symbol viewBox="0 0 8 7" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-check">
                <path d="M1 4.00001L2.66667 5.80001L7 1.20001" stroke="var(--icon-stroke)" stroke-width="1" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-tick">
                <path d="M2 9.66667L5.33333 13L14 3" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/>
        </symbol>

        <symbol viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" id="icon-dot-horizontal">
                <path fill-rule="evenodd" clip-rule="evenodd" d="M5 8C5 8.55228 4.55228 9 4 9C3.44772 9 3 8.55228 3 8C3 7.44772 3.44772 7 4 7C4.55228 7 5 7.44772 5 8ZM8 9C8.55228 9 9 8.55228 9 8C9 7.44772 8.55228 7 8 7C7.44772 7 7 7.44772 7 8C7 8.55228 7.44772 9 8 9ZM12 9C12.5523 9 13 8.55228 13 8C13 7.44772 12.5523 7 12 7C11.4477 7 11 7.44772 11 8C11 8.55228 11.4477 9 12 9Z" stroke="none" fill="var(--icon-stroke)"/>
        </symbol>

        <symbol viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" id="icon-dot-vertical">
                <path fill-rule="evenodd" clip-rule="evenodd" d="M8 5a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm0 4a1 1 0 1 0 0-2 1 1 0 0 0 0 2zm1 3a1 1 0 1 1-2 0 1 1 0 0 1 2 0z" stroke="none" fill="var(--icon-stroke)"></path>
        </symbol>

        <symbol viewBox="0 0 12 12" xmlns="http://www.w3.org/2000/svg" id="icon-drag">
                <path fill-rule="evenodd" clip-rule="evenodd" d="M4.875 1.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0 9a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm-1.5-3a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm6.75-6a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zM8.625 12a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm1.5-6a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z"
                fill="#ACB5BD" stroke-width="0"></path>
        </symbol>

        <symbol viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" id="icon-drag-sm">
                <path fill-rule="evenodd" clip-rule="evenodd" d="M6.9 3a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0 10a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zM5.4 9.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zM12.15 3a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm-1.5 11.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3zm1.5-6.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0z"
                fill="#ACB5BD" stroke="none" stroke-width="0"></path>
        </symbol>

        <symbol viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" id="icon-dialpad">
                <path stroke="none" d="M5.5 14C6.32843 14 7 13.3284 7 12.5C7 11.6716 6.32843 11 5.5 11C4.67157 11 4 11.6716 4 12.5C4 13.3284 4.67157 14 5.5 14Z" fill="var(--icon-stroke)"/>
                <path stroke="none" d="M10 14C10.8284 14 11.5 13.3284 11.5 12.5C11.5 11.6716 10.8284 11 10 11C9.17157 11 8.5 11.6716 8.5 12.5C8.5 13.3284 9.17157 14 10 14Z" fill="var(--icon-stroke)"/>
                <path stroke="none" d="M10 18.5C10.8284 18.5 11.5 17.8284 11.5 17C11.5 16.1716 10.8284 15.5 10 15.5C9.17157 15.5 8.5 16.1716 8.5 17C8.5 17.8284 9.17157 18.5 10 18.5Z" fill="var(--icon-stroke)"/>
                <path stroke="none" d="M5.5 5C6.32843 5 7 4.32843 7 3.5C7 2.67157 6.32843 2 5.5 2C4.67157 2 4 2.67157 4 3.5C4 4.32843 4.67157 5 5.5 5Z" fill="var(--icon-stroke)"/>
                <path stroke="none" d="M10 5C10.8284 5 11.5 4.32843 11.5 3.5C11.5 2.67157 10.8284 2 10 2C9.17157 2 8.5 2.67157 8.5 3.5C8.5 4.32843 9.17157 5 10 5Z" fill="var(--icon-stroke)"/>
                <path stroke="none" d="M14.5 5C15.3284 5 16 4.32843 16 3.5C16 2.67157 15.3284 2 14.5 2C13.6716 2 13 2.67157 13 3.5C13 4.32843 13.6716 5 14.5 5Z" fill="var(--icon-stroke)"/>
                <path stroke="none" d="M14.5 14C15.3284 14 16 13.3284 16 12.5C16 11.6716 15.3284 11 14.5 11C13.6716 11 13 11.6716 13 12.5C13 13.3284 13.6716 14 14.5 14Z" fill="var(--icon-stroke)"/>
                <path stroke="none" d="M5.5 9.5C6.32843 9.5 7 8.82843 7 8C7 7.17157 6.32843 6.5 5.5 6.5C4.67157 6.5 4 7.17157 4 8C4 8.82843 4.67157 9.5 5.5 9.5Z" fill="var(--icon-stroke)"/>
                <path stroke="none" d="M10 9.5C10.8284 9.5 11.5 8.82843 11.5 8C11.5 7.17157 10.8284 6.5 10 6.5C9.17157 6.5 8.5 7.17157 8.5 8C8.5 8.82843 9.171
Error creating Purchase Order: Expecting value: line 1 column 1 (char 0)

My Function definition

def create_purchase_order(supplier):
    tansaction_date = generate_random_date()
    purchase_order = {
        "doctype": "Purchase Order",
        "supplier": supplier["name"],
        "transaction_date": tansaction_date,
        "items": get_item_list(),
        "schedule_date": generate_random_date(tansaction_date)
    }
    try:
        response = client.insert(purchase_order)
        print("Purchase Order created successfully:", response["name"])
        getPO = client.get_doc("Purchase Order",response["name"])
        
        submit_response = client.submit([getPO])
        print("Purchase Order submitted successfully:", submit_response)
        return response["name"]
    except Exception as e:
        print(f"Error creating Purchase Order: {str(e)}")

        return None