How to return all fields when listing using REST Api?

Hello Team,

I’m being diving how to retrieve all fields when listing a doc_type thru REST Api. Let’s say instead of explicitly asking for each field by its name, I would like to know if something like this: “https://demo.erpnext.com/api/resource/Currency Exchange/?fields=all” is possible.

Thanks in advance,

Alirio.

2 Likes

Hello @aliriocastro

You may retrieve all fields using this.
https://demo.erpnext.com/api/resource/Currency Exchange?fields=["*"]

Just refer to the file below

Regards,

Ivan

2 Likes

Thank you Ivan,

Just to confirm. IT WORKS !!!

Regards,

Alirio.

1 Like

Hi
A related query would be how to list all child table rows. For example in quality inspection, how to fetch rows in quality inspection template?

Any ideas?

GET /api/resource/Quality Inspection Template?fields=[“item_quality_inspection_parameter”]

Hello @rmeyer

For example, I need to bring all items from Sales Invoice with this query

GET /api/resource/Sales Invoice/?fields=[“items”]

But it does not work.

Throw this error:
InternalError: (1054, u"Unknown column ‘items’ in ‘field list’")

Please request a single invoice to get the items. In the list of invoices, child tables are not included.

You can GET /api/resource/Sales Invoice for a list of invoice names. Then loop over the list and GET /api/resource/Sales Invoice/{current_invoice}. The latter will return all invoice data, including the items.

1 Like

It would have been nice if at least listing items from child tables was possible. Instead of sending 20 get requests to the api to deeply fetch the parent it would be done in a single one and a filter like [['Material Request Item', 'parent', 'in', ['name1', 'name2', ...]]]

That would be much faster and close enough to a join for me.

But erpnext just keeps responding “Broken Pipe Error”. great. So instead I’ll just wait a few seconds each time the page refreshes for all requests to resolve… great user experience

1 Like

Hi @sezanzeb

Did you create a Github Issue for this ?

Kind regards,