How to validate a VAT number in Salesforce Apex
1 min readFeb 18, 2020
This tutorial is going to take you through an ultra-quick solution to your VAT validation quandaries.
To start, we need to download the Cloudmersive Validation API client and unzip it into our project folder.
Now call vatVatLookup with our VAT code.
SwagVatApi api = new SwagVatApi();SwagClient client = api.getClient();// Configure API key authorization: ApikeyApiKeyAuth Apikey = (ApiKeyAuth) client.getAuthentication('Apikey');Apikey.setApiKey('YOUR API KEY');Map<String, Object> params = new Map<String, Object>{'input' => SwagVatLookupRequest.getExample()};try {// cross your fingersSwagVatLookupResponse result = api.vatVatLookup(params);System.debug(result);} catch (Swagger.ApiException e) {// ...handle your exceptions}
Oh look, we’re done. Pretty painless, no? If you want more painless solutions like this, our APIs have got you covered.