Get child table data from post request


def create_consumer(**args):

doc1 = frappe.new_doc("pq_consumer")


        "callback_url" : (args["current_site_url"]),




        "consumer_doctypes": json.loads(args["consumer_doctypes"])



Hi @praveenkumarcse2211,

Please check the syntax with your code:

import json

def create_consumer(**args):
    doc1 = frappe.new_doc("pq_consumer")
    # Retrieve the child table data from the POST request
    consumer_doctypes = json.loads(args["consumer_doctypes"])
    # Create child table entries
    for data in consumer_doctypes:
        child_table_entry = doc1.append("child_table_fieldname", {})
        child_table_entry.field1 = data["field1"]
        child_table_entry.field2 = data["field2"]
        # Set other fields as per your child table structure
    # Set other fields of the main document
    doc1.callback_url = args["current_site_url"]
    doc1.api_key = args["api_key"]
    doc1.api_secret = args["api_secret"]
    doc1.user = args["user"]

    # Save the document

I hope this helps.
Thank You!


Thanks @NCP, its working