web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Bussiness Central API v2 Create Customer Posting Group Error

(3) ShareShare
ReportReport
Posted on by

I am unable to create a new customer through the business central api :

 https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/api-reference/v2.0/api/dynamics_customer_create

Providing the following request body:

{
    "number": "TCUST",
    "displayName": "Test Customer"
}
     

results in the following error:  

{
    "error": {
        "interface": "error-object",
        "main": {
            "status": 500,
            "msg": "The field Gen. Bus. Posting Group of table Customer contains a value (DOMESTIC) that cannot be found in the related table (Gen. Business Posting Group).  ",
            "db": false,
            "title": "msbcbase => request => https://api.businesscentral.dynamics.com/v2.0/tenant/sandbox/api/v2.0/companies(companyId)/customers",
            "data": {
                "message": "Request failed with status code 400",
                "name": "Error",
                "stack": "Error: Request failed with status code 400\n    at createError (path)\n    at settle (path)\n    at IncomingMessage.handleStreamEnd (path)\n    at IncomingMessage.emit (events.js:327:22)\n    at endReadableNT (internal/streams/readable.js:1327:12)\n    at processTicksAndRejections (internal/process/task_queues.js:80:21)",
                "config": {
                    "url": "https://api.businesscentral.dynamics.com/v2.0/tenant/sandbox/api/v2.0/companies(companyId)/customers",
                    "method": "post",
                    "data": "{\"number\":\"TCUST\",\"displayName\":\"Test Customer\"}",
                    "headers": {
                        "Accept": "application/json, text/plain, */*",
                        "Content-Type": "application/json",
                        "Authorization": "token",
                        "User-Agent": "axios/0.21.4",
                        "Content-Length": 48
                    },
                    "params": {},
                    "transformRequest": [
                        null
                    ],
                    "transformResponse": [
                        null
                    ],
                    "timeout": 0,
                    "xsrfCookieName": "XSRF-TOKEN",
                    "xsrfHeaderName": "X-XSRF-TOKEN",
                    "maxContentLength": -1,
                    "maxBodyLength": -1,
                    "transitional": {
                        "silentJSONParsing": true,
                        "forcedJSONParsing": true,
                        "clarifyTimeoutError": false
                    }
                }
            }
        }
    }
}

After doing some research I thought i may be able to provide the posting group within the request body as suggested in this question:

   

{
    "number": "TCUST",
    "displayName": "Test Customer",
    "Gen. Bus. Posting Group": "DEFAULT"
}

Default is a valid posting group and this did not work either. Any other suggestions?

update, i created the DOMESTIC posting group it defaults to and it works fine but i still need to know how to actually set it to a valid one through the api.

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at

    Hi,

    You have to check with Page : Gen. Business Posting Group and check what are the codes available, and you have to select one of them and put in the request body with that field, and see if problem solves.

    Thanks.

  • AB-24031503-0 Profile Picture
    12 on at
    If you ever figured it out, let me know

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,377

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,696 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,512 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans