Creating a customer record in Microsoft Dynamics 365 Business Central is a topic I blogged about in one of my previous blog posts. If you have not read them yet I suggest you read it before going through this for better understanding.
Part 01: Getting Started with Dynamics 365 Business Central APIs
Part 02: Understanding Microsoft Business Central Out-Of-The-Box API Endpoints
Part 03: Understanding Microsoft Business Central Custom API Endpoints
If you want to insert below address to Business Central Customer Card then how would your JSON body look like?
|
Field Name in BC
|
Data to inject
|
|
Address
|
2/34
|
|
Address 2
|
Coliseum Drive
|
|
City
|
Albany
|
|
County
|
Auckland
|
|
Country
|
NZ
|
|
Postal Code
|
0632
|
First Attempt:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
{
"number": "CUST0012",
"displayName": "Tailspin Toys",
"type": "Company",
"email": "jordan.moresby@contoso.com",
"currencyCode": "NZD",
"address": {
"street": "2/34, Coliseum Drive ",
"city": "Albany",
"state": "Auckland",
"countryLetterCode": "NZ",
"postalCode": "0632"
}
}
|
Outcome :
As you can see the first attempt did not work as expected. Address and Address 2 both end up in one field.
Second Attempt :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
{
"number": "CUST0012",
"displayName": "Tailspin Toys",
"type": "Company",
"email": "jordan.moresby@contoso.com",
"currencyCode": "NZD",
"address": {
"street": "2/34, rnColiseum Drive ",
"city": "Albany",
"state": "Auckland",
"countryLetterCode": "NZ",
"postalCode": "0632"
}
}
|
Outcome:
It did work and the “Address 2” field gets filled with the data we wanted. The change I did was I added rn into my JSON body. rn is used as a newline character in Windows and this is a very common way to go to a new line.
rn = CR + LF → Used as a new line character in Windows
Please provide your feedback with a comment.
Thank you and Regards,
Tharanga Chandrasekara


2 comments
Thanks for sharing this tip Tharanga. Genius! I struggled to believe that Microsoft had left such a glaring hole in their API! This should be stated in their documentation and given as an example in their complex data type.
Absolute legend my friend! Just what I needed 🙂
Big thanks!!!