跳到主要内容

Rest API

内部调用

Doctype CRUD 操作:

POST:  /api/resource/{doctype}
GET: /api/resource/{doctype}/{name}
PUT: /api/resource/{doctype}/{name}
DELETE: /api/resource/{doctype}/{name}

GET 查询

GET /api/resource/Sales Order
?filters=[["customer","=","Frappe shcool"]]
&fields=["name","grand_total"]
&order_by=creation desc

外部调用

服务端文件结构:

app/module/file.py
@frappe.whitelist()
def greet(name):
return f"Hello,{name}"

客户端调用

POST /api/method/app.module.file.greet
{"name": "JImmy"}

响应:

{
"message": "Hello,Jimmy"
}

WebHooks调用

From ERPNext to Telegram

ERPNext

Doctye: Sales Order

Hook: on_submit

Condition: doc.via_ecommerce

//request body simplified

{

"chat_id": 1310788794

"text": "New Order from {{doc.customer}}",

"url": "{{frappe.utils.get_url_to_form(doc.doctype,doc.name)}}"

}

Telegram:

post

api.telegram.org /token/sendMessage