> For the complete documentation index, see [llms.txt](https://docs.mastersoftgroup.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mastersoftgroup.com/loqate-harmony-api/integrations/deprecated-integrations/harmony-rightaddress-c-example.md).

# Harmony RightAddress c# example

This is an example of how to call Harmony RightAddress REST API using c#.

The following example invokes REST request for the address method with the single line address '220 George St' and the 'AUPAF' reference data set (Source of Truth):

```
			
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace HarmonyHostedClient
{
    class Program
    {
        // the end point for which environment to access
        private const string END_POINT 
                = "https://hosted.mastersoftgroup.com/harmony/rest/au/address";

        // Go to https://hosted.mastersoftgroup.com/console to get user/credential
        private const string USER = "user"; 
        private const string CREDENTIAL = "credential";

        // the reference data set (SOT): AUPAF, GNAF, and etc
        private const string SOT = "AUPAF";

        static void Main(string[] args)
        {
            string result = lookupAddress("220 George St");
            Console.WriteLine(result);
            System.Diagnostics.Debug.WriteLine(result);
        }

        static string lookupAddress(string escapedInput)
        {
            var httpWebRequest = (HttpWebRequest)WebRequest.Create(END_POINT);
            httpWebRequest.ContentType = "application/json";
            httpWebRequest.Method = "POST";

            // authentication
            string encoded = Convert.ToBase64String(
                    Encoding.GetEncoding("ISO-8859-1").GetBytes(USER + ":" + CREDENTIAL));
            httpWebRequest.Headers.Add("Authorization", "Basic " + encoded);

            using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
            {
                // make sure input is escaped
                string json = "{ \"payload\": [{ \"fullAddress\": \"" +escapedInput+ "\"}], " +
                                  " \"sourceOfTruth\": \""+SOT+"\"}";

                streamWriter.Write(json);
            }

            // may need to handle exceptions
            var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var responseText = streamReader.ReadToEnd();
                return responseText;
            }
        }
    }
}

```

See the [Harmony RightAddress API](/loqate-harmony-api/api-specification.md) documentation for details on invoking the other Harmony RightAddress service methods.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mastersoftgroup.com/loqate-harmony-api/integrations/deprecated-integrations/harmony-rightaddress-c-example.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
