How to call rest API for rename, cancel and submit


I am working with rest API using python and in that I am succeeded with get, post, put, delete operations for Master data like item, supplier, customer. But don’t know how to rename, cancel and submit the existing document. Please anyone help me on this.

You can create a document by sending a PUT request to the endpoint, /api/resource/{doctype}/{name} . This acts like a PATCH HTTP request in which you do not have to send the whole document but only the parts you want to change.

Hi @youssef,

Here is my code like what you said, but it doesn’t work for just renaming the existing customer from POST to POST1

import requests
import json
def send_to_erpnext():
    url = ""
    headers = {
        'Authorization': "token "+ "xxxxxxxx" + ":" + "xxxxxxxx",
        'Accept': 'application/json'
    data = {"customer_name": "POST1", "gst_status":"Registered Dealer", "constitution":"LLP", "customer_group":"PT/TirupurExporter", "territory":"Tamil Nadu", "customer_type": "Company"}
    all_data = json.dumps(data)
    text = []
    response = []
    response = requests.request("PUT", url, headers=headers, data=all_data)


Please do the needful.

you can see this Unofficial documentation of the Frappe / ERPNext API.

and this:

Hi @youssef,

First I wish to say thanks for your response. I saw your link and read the documentation, In that you have mentioned the code for update the specific document using put method, which I have already tried and got success.

But here i am seeking help for renaming, cancelling and amending the document. Kindly do the needful.

1 Like

Have you tried this solution?

For cancelling doc :

and for submit you can use same method with {“docstatus”: 1}

Hi @youssef,

Thanks for your response, I have tried using online editor to import frappe, but got a error and also I have doubt in when to call this rename function, whether after rest API or before API. Could you please help via screen sharing.
Kindly do the needful.

you have create this function in a custom app and then call it from api with /api/method/{}

Hi @youssef,

Can I import this frappe module in Django framework, will it work? Kindly let me know.

Thanks in advance.

As I now you can’t do this.

@youssef Is there way to submit the sales invoice using rest API in tkinter python? Please help me on this.

@youssef @IT_Department I send a PUT request to /api/resource/Attendance/{name} with data = {“docstatus”: 2} but getting Internal Server Error. Can anyone help me out in this. I wanted to make a change in my submitted document but can’t cancel it using the restAPI and also there is no info about the same on ERPNext doc. I am using authorizing using token and passing data in data and in json both and getting INTERNAL SERVER ERROR in both the cases.

This question does not make much sense. Frappe framework is built with bench. Its a whole different framework to Django. You can use both backends side by side and have data sent to/from, but frappe is not an app or middlewhere you can just include in your django project. What are you trying to achieve?