How to insert to child table in doctype using API

Hello ,
How to insert or Update into child table using rest api

lets say we need to PUT into
http://0.0.0.0:8000/api/resource/Products/PRD0000001
where there child table called Categories_Products

the json when GET is

"data": {
 "status": "Disable",
 "products_Tags_Type_Tags": [ ],
"barcode": "1256479632145",
"modified_by": "Administrator",
"name": "PRD0000001",
 "parent": null,
"title": "حليب المراعي 250 ملم شوكولاته",
"price": 5,
"creation": "2015-02-06 10:07:08.646843",
 "modified": "2015-02-08 19:21:34.203954",
"doctype": "Products",
"idx": null, 
 "parenttype": null,
"catagory": [
{
 "modified_by": "Administrator",
 "name": "e1e4d5509b15516845f67b3e53932e6b7655204d40c1a63f0b9dbfa6",
 "parent": "PRD0000001",
 "creation": "2015-02-06 10:07:08.646843",
 "modified": "2015-02-08 19:21:34.203954",
 "doctype": "Categories_Products",
 "idx": 1,
"parenttype": "Products",
"owner": "Administrator",
"docstatus": 0,
 "categories": "CAT00001",
  "parentfield": "catagory"
   }
       ]       ,
       "descriptions": "حليب شوكلاته المراعي ",
         "owner": "Administrator",
      "docstatus": 0,
         "image": "http://bo7.net/wp-content/uploads/2014/01/large__0047_UHT250ml-CB1-chocolate.jpg",
        "parentfield": null
      }
       }

any one ?
how to insert or update Child table using the API ?
and thanks in advance

Yes, you can pass a list,
For example, if the table field name is accounts, you can send a PUT request like
data = {“accounts”: [{“account”: “Debtors - WP”,“company”: “Wind Power LLC”}]}

sending this to /api/resource/Customer/Customer_Name (in v5) would create a child record for party account and attach it to the customer.

I am trying to do as you said but i get this error:

Traceback (innermost last): File "/home/frappe/press/benches/1606030840/apps/frappe/frappe/app.py", line 60, in application response = frappe.api.handle() File "/home/frappe/press/benches/1606030840/apps/frappe/frappe/api.py", line 116, in handle "data": frappe.get_doc(data).insert().as_dict() File "/home/frappe/press/benches/1606030840/apps/frappe/frappe/model/base_document.py", line 241, in as_dict doc[df.fieldname] = [d.as_dict(no_nulls=no_nulls) for d in children] AttributeError: 'unicode' object has no attribute 'as_dict'

please Advise.

Regards

I am trying to do as you said but it not work

sending this to api/resource/Customer/CUST-00025

For example, if the table field name is customer_sub_profile , you can send a PUT request like

data = {“customer_sub_profile” : [ {“full_name” : “ram”,“date_of_birth” : “1993-10-23”]}}