Librerie client dell'API Address Validation

Questa pagina mostra come iniziare a utilizzare le librerie client per l'API Address Validation.

Per ulteriori informazioni sulle librerie client, consulta la pagina Spiegazione delle librerie client.

Installare la libreria client

C#

Per ulteriori informazioni, consulta la sezione Configurazione di un ambiente di sviluppo C#.

Install-Package Google.Maps.AddressValidation.V1 -Pre

Configurazione dell'autenticazione

Quando usi le librerie client, per l'autenticazione vengono usate le credenziali predefinite dell'applicazione (ADC). Per informazioni sulla configurazione di ADC, consulta Fornire le credenziali per le credenziali predefinite dell'applicazione. Per informazioni sull'utilizzo di ADC con le librerie client, consulta Autenticazione tramite librerie client.

Utilizzo della libreria client

C#

using Google.Maps.AddressValidation.V1;
using Google.Type;
using System.Threading.Tasks;

public sealed partial class GeneratedAddressValidationClientSnippets
{
    /// <summary>Snippet for ValidateAddressAsync</summary>
    /// <remarks>
    /// This snippet has been automatically generated and should be regarded as a code template only.
    /// It will require modifications to work:
    /// - It may require correct/in-range values for request initialization.
    /// - It may require specifying regional endpoints when creating the service client as shown in
    ///   https://cloud.google.com/dotnet/docs/reference/help/client-configuration#endpoint.
    /// </remarks>
    public async Task ValidateAddressRequestObjectAsync()
    {
        // Create client
        AddressValidationClient addressValidationClient = await AddressValidationClient.CreateAsync();
        // Initialize request argument(s)
        ValidateAddressRequest request = new ValidateAddressRequest
        {
            Address = new PostalAddress(),
            PreviousResponseId = "",
            EnableUspsCass = false,
            SessionToken = "",
        };
        // Make the request
        ValidateAddressResponse response = await addressValidationClient.ValidateAddressAsync(request);
    }
}

Risorse aggiuntive