Unable to create chart of account via REST API

I’m currently trying to create a new account (Chart of Accounts) via the REST API. Currently, I"m able to retrieve the list of accounts. However, when I try creating a new one, it just returns me a list of accounts instead.

Appreciate if anyone could tell me what I’m doing incorrectly would be great.

POST api/resource/Account/
Body request as below:

{
   "name":"Test Account - MD",
   "account_name":"Test Account",
   "root_type":"Asset",
   "report_type":"Balance Sheet",
   "account_currency":"MYR",
   "parent_account":"Current Assets - M",
   "account_type":"Bank",
}

The response I got is just the list of accounts:

{
    "data": [
        {
            "name": "Application of Funds (Assets) - M"
        },
        {
            "name": "Current Assets - M"
        },
        {
            "name": "Accounts Receivable - M"
        },
        {
            "name": "Debtors - M"
        },
        {
            "name": "Bank Accounts - M"
        },
        {
            "name": "Bank Account - M"
        },
        {
            "name": "Cash In Hand - M"
        },
        {
            "name": "Cash - M"
        },
        {
            "name": "Loans and Advances (Assets) - M"
        },
        {
            "name": "Employee Advances - M"
        },
        {
            "name": "Securities and Deposits - M"
        },
        {
            "name": "Earnest Money - M"
        },
        {
            "name": "Stock Assets - M"
        },
        {
            "name": "Stock In Hand - M"
        },
        {
            "name": "Tax Assets - M"
        },
        {
            "name": "Fixed Assets - M"
        },
        {
            "name": "Accumulated Depreciation - M"
        },
        {
            "name": "Buildings - M"
        },
        {
            "name": "Capital Equipments - M"
        },
        {
            "name": "CWIP Account - M"
        }
    ]
}

You posted an account seemingly belonging to Company “MD” which you say has a parent account for a Company “M”.

I’m not sure if this works like that, and
if this was intentional from your part.

You can find parts of the chart of accounts setup in the module setup, e.g.:

<yourbenchspath>/v15/apps/erpnext/erpnext/setup$ grep -ir "chart of accounts" *

You can find doctypes in the modules like this (here: searching for doctypes with “account” in the name):

<yourbenchspath>/v15/apps/erpnext/erpnext$ find */doctype/*/*.py | grep -i account

Thanks for the feedback. I’ve updated the name to match, but the result is still the same.

So I created a new account manually via the ERPNext portal, and then retrieved the data via the API. Using back this same data JSON, I input in as the body request for creating a new account, and edited the name of the account. However, the results are still the same where it returns me the list of accounts without creating a new account. The response of the API is 200 with no error. This boggles me as the new account is not created.

Replaced any sensitive information such as email in this post.

GET /api/resource/Account/Test Account - MD

 "data": {
        "name": "Test Account - MD",
        "owner": "owner@test.com",
        "creation": "2024-06-17 16:28:14.520526",
        "modified": "2024-06-17 16:28:14.520526",
        "modified_by": "owner@test.com",
        "docstatus": 0,
        "idx": 0,
        "disabled": 0,
        "account_name": "Test Account",
        "is_group": 0,
        "company": "Test (Demo)",
        "root_type": "Asset",
        "report_type": "Balance Sheet",
        "account_currency": "MYR",
        "parent_account": "Bank Accounts - MD",
        "account_type": "Bank",
        "tax_rate": 0.0,
        "freeze_account": "No",
        "balance_must_be": "",
        "lft": 66,
        "rgt": 67,
        "old_parent": "Bank Accounts - MD",
        "include_in_gross": 0,
        "doctype": "Account"
    }
}

POST /api/resource/Account/

{
   "name":"Test Account 2 - MD",
   "owner":"owner@test.com",
   "creation":"2024-06-17 16:28:14.520526",
   "modified":"2024-06-17 16:28:14.520526",
   "modified_by":"owner@test.com",
   "docstatus":0,
   "idx":0,
   "disabled":0,
   "account_name":"Test Account 2",
   "is_group":0,
   "company":"Test (Demo)",
   "root_type":"Asset",
   "report_type":"Balance Sheet",
   "account_currency":"MYR",
   "parent_account":"Bank Accounts - MD",
   "account_type":"Bank",
   "tax_rate":0.0,
   "freeze_account":"No",
   "balance_must_be":"",
   "lft":66,
   "rgt":67,
   "old_parent":"Bank Accounts - MD",
   "include_in_gross":0,
   "doctype":"Account"
}