You cannot simply send an update request for a document and change its status to “Closed” in ERPNext.
In order to change the status of already submitted document to “Closed” you need to call the API: /api/method/erpnext.selling.doctype.sales_order.sales_order.close_or_unclose_sales_orders
You can use POST call to the API as follow:
https://{ERPURL}/api/method/erpnext.selling.doctype.sales_order.sales_order.close_or_unclose_sales_orders?names=[“SO25000008”]&status=Closed
or using the following Python code:
import requests
headers = {
"Authorization": f"token {API_KEY}:{API_SECRET}",
"Content-Type": "application/json",
}
url = f"{ERP_URL}/api/method/erpnext.selling.doctype.sales_order.sales_order.close_or_unclose_sales_orders?names=[\"{name}\"]&status=Closed"
response = requests.post(url, headers=headers)
print(response.status_code)