Skip to main content

Notifications

Announcements

No record found.

How to inject data to Customer Address Line 2 using Microsoft Business Central API

 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, \r\nColiseum 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 \r\n into my JSON body. \r\n is used as a newline character in Windows and this is a very common way to go to a new line. 

 \r\n = CR + LF → Used as a new line character in Windows  

Please provide your feedback with a comment. 
Thank you and Regards,
Tharanga Chandrasekara

This was originally posted here.

Comments

*This post is locked for comments