In the Frappe Documentation Listing Documents it reads:
To list documents, make a GET request to /api/resource/{doctype}.
GET /api/resource/Person
-What is the Doctype for Quotation Item? It is not url/api/resource/Quotation Item AFAIK
-How is one supposed to get the Quotation Items?
I am trying to fetch them from an external Vanilla JS app. I have no problem with Sales Invoice, Quotation, etc but with getting their child items.
ERPNext application uses APIs under the hood. One hack that I’ve found is to watch the terminal for logs and look for GET requests
for any resource whose URL you’re trying to figure out. Another hack is to simply do SHOW TABLES;
on you DB. There is one-to-one mapping between DocType
, Resource
and Table
. E.g. tabQuotation Item
corresponds to Quotation Item
DocType
-What is the Doctype for Quotation Item? It is not url/api/resource/Quotation Item AFAIK
This seems to be correct, end-point’s URL would beurl/api/resource/Quotation Item/<name>
, here <name>
is Quotation Item
’s name
-How is one supposed to get the Quotation Items?
You can apply LIKE
filter {referencing name of parent DocType}, e.g. see this test for frappe-client, specifically look for test_get_doc_with_no_doc_name
.
Child documents are not first class due to complex permission rules that may be applied on the parent. You can query parent objects or write your own whitelisted method to return child documents.
-How do I query parent objects in order to retrieve their child documents, @rmehta?
Why not do a forum search or browse the code for example clues close to what you seek?
The idea is to benefit and learn from other q&a posts - these may help
Filter Child table base on parent field
Filter Child Table Based on Child Field using Query
How to Filter child table
Custom apps for cloud users [extend ERPNext with microservices] - #6 by revant_one
Then followup here what snags you overcame, for you and the rest of us to refer to and learn.
The answer to my question is that there is no way to get the Child Documents of a Doctype through Rest Api, because the foreign key is in the Child Table (through the “parent” fieldname of the Child Table), and as @rmehta said:
Child documents are not first class due to complex permission rules that may be applied on the parent
One has to write our own whitelisted method and call that method through an RPC Call.
Yes one at a time is possible since you can query the parent for permissions. Child queries should be possible in theory given permissions are checked and would be a valid feature if contributed.
1 Like