API Call - Create Customer / Contact / Address

Good Day

Could anyone give me direction:

If i create a Customer with API Call do i need to Do 2 separate calls to create Contact and Address?

Could someone please show me how to if code in Python?

Thank You

Albertus Geyser

If you pass contact and address details such as Email and Mobile No, while creating the customer, contact and address docs will be created transparently for you and get linked to your new customer

POSTing this

	"customer_group": "Commercial", 
	"territory": "All Territories", 
	"customer_type": "Company", 
	"customer_name": "Customer 1",
	"email_id": "rrrrr@test.com",
	"mobile_no": "4544545454"

to /api/resource/Customer should do the trick

1 Like

Good Day

Thank you, will try and let you know.


Good Day @RWEMA_Aimable

I tested and working wonderful.

Could you help to explain how i would set primary Address?

Good Day

Your help helped me allot. Thank You

Could you assist to undertand how i would create Order with multiple items via api?

Thank You

Albertus Geyser

You can start from here:

doc = {
            "doctype": "Sales Order",
            "customer": sale_order['partner_name'],
            "title": sale_order['name'],
            "contact_display": sale_order['name'],
            "order_type": "Sales",
            "transaction_date": str(sale_order['date_order']),
            "delivery_date": str(sale_order['date_order']),
            "company": "CCCCCCCCCCCCCCC",
            'currency': 'RWF',
            'conversion_rate': 1.0,
            'selling_price_list': 'Standard Selling',
            'price_list_currency': 'RWF',
            'plc_conversion_rate': 1.0,
            'naming_series': 'SO-',
            'order_type': 'Sales',
            'status': 'Draft',
                       'qty': float(sale_order['product_uos_qty']),
                       'doctype':'Sales Order Item',
                       'rate': float(sale_order['price_unit'])
1 Like

@RWEMA_Aimable @Albertus Hello, I was following the procedure but “Could you help to explain how i would set primary Address?” How to do this?