How to validate a VAT number in Salesforce Apex

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.

Image for post
Image for post

Written by

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store