The following steps demonstrate how to use the Auto-complete control to display address suggestions from the New Zealand Post Address API:
1. Obtain New Zealand Post Client Id and Secret
When you register with New Zealand Post and set up your free account, a Client Id and Client Secret would be generated which will be used in every HTTP request to the New Zealand Post Address API
2. Setup the on key press event
Bind the on key press event of a single-line text field. This converts the single-line of text control to an Auto-complete control.
3. Pass the input text value on every key press
For every key press against the field obtain the field value and pass to the getSuggestions() function
Generate the New Zealand Post API query string by concatenating the New Zealand Post API URL, Client Id, Client Secret and field value.
Send a HTTP request to the New Zealand POST API and process the response. A successful HTTP Status 200 response will contain JSON data which is parsed and added to an array of Address Suggestion objects.
That’s all there is to it. A small amount of work to improve the user experience and also ensure that accurate address data is stored in your Dynamics 365 system.