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.