Checking a Spanish #VAT number using the #VIES webservice in C#

Checking EU VAT numbers using the VIES webservice has some quirks, for example, in Germany, only the validity of the number can be verified, and in Spain, although the company name and address are not exposed, the API can be used to verify them against provided details, for this, a different service method needs to be used for Spain, than for other countries;
TL; DR; here is the Github Repo showing the code in c# https://github.com/infiniteloopltd/CheckVatNumberSpain
Checking a VAT number in Spain can be done by using the European Union’s VAT Information Exchange System (VIES). VIES is a web-based system that allows businesses and tax authorities in the EU to verify the validity of VAT numbers assigned to companies in other EU member states.
To check a VAT number in Spain using VIES, you would need to make a SOAP web service request to the VIES web service endpoint, passing in the VAT number you wish to validate as a parameter. The request would be sent to the VIES service over HTTPS, ensuring the data transmitted is secure.
The VIES service would then respond with a validation result indicating whether the VAT number is valid or not. If the VAT number is valid, the response would also include the country code of the member state that issued the VAT number. The VIES service does not expose the name or address of the company.
Added in the code is a inspector that prints to the console the XML being sent and received, for use in Postman, or another client that needed to POST the XML via HTTP rather than SOAP; which would be;
Sample Request
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<checkVatApprox xmlns="urn:ec.europa.eu:taxud:vies:services:checkVat:types">
<countryCode>ES</countryCode>
<vatNumber>B83891812</vatNumber>
<traderName>Rodrisa Automoviles</traderName>
<traderCompanyType />
<traderStreet>Avda. Reina Victoria</traderStreet>
<traderPostcode>28430</traderPostcode>
<traderCity>Madrid</traderCity>
<requesterCountryCode />
<requesterVatNumber />
</checkVatApprox>
</s:Body>
</s:Envelope>
Sample Response
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Header/>
<env:Body>
<ns2:checkVatApproxResponse xmlns:ns2="urn:ec.europa.eu:taxud:vies:services:checkVat:types">
<ns2:countryCode>ES</ns2:countryCode>
<ns2:vatNumber>B83891812</ns2:vatNumber>
<ns2:requestDate>2023-01-12+01:00</ns2:requestDate>
<ns2:valid>true</ns2:valid>
<ns2:traderName>Rodrisa Automoviles</ns2:traderName>
<ns2:traderCompanyType></ns2:traderCompanyType>
<ns2:traderStreet>Avda. Reina Victoria</ns2:traderStreet>
<ns2:traderPostcode>28430</ns2:traderPostcode>
<ns2:traderCity>Madrid</ns2:traderCity>
<ns2:traderNameMatch>1</ns2:traderNameMatch>
<ns2:traderCompanyTypeMatch>3</ns2:traderCompanyTypeMatch>
<ns2:traderStreetMatch>1</ns2:traderStreetMatch>
<ns2:traderPostcodeMatch>1</ns2:traderPostcodeMatch>
<ns2:traderCityMatch>2</ns2:traderCityMatch>
<ns2:requestIdentifier></ns2:requestIdentifier>
</ns2:checkVatApproxResponse>
</env:Body>
</env:Envelope>
Clearing out #AWS #Cloudwatch in C# – Coded with help from #ChatGPT

If you’re like me, you use AWS Cloudwatch when testing and debugging your Lambda functions on AWS, and then whenever your code is working, you end up leaving them in, “just in case” – Of course, that means you ignore them, until you get a bill from AWS for holding GB’s of logs, for no reason whatsoever.
So, here’s some C# code (Coded with the help of ChatCPT OpenAI with some modifications), to clear out all your Cloudwatch logs in all regions. You can be less heavy-handed, but I wanted to delete everything.
using Amazon;
using Amazon.CloudWatchLogs;
using Amazon.CloudWatchLogs.Model;
using Amazon.Runtime;
class Program
{
static void Main(string[] args)
{
const string accessKey = "xxxxxxxxxxxxxxx";
const string secretKey = "xxxxxxxxxxxxxxx";
var credentials = new BasicAWSCredentials(accessKey, secretKey);
foreach (var region in Amazon.RegionEndpoint.EnumerableAllRegions)
{
Console.WriteLine(region.SystemName);
var client = new AmazonCloudWatchLogsClient(credentials, region);
try
{
// Get a list of all log groups
DescribeLogGroupsResponse logGroupsResponse = null;
try
{
logGroupsResponse = client.DescribeLogGroupsAsync().Result;
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
continue;
}
var logGroups = logGroupsResponse.LogGroups;
// Iterate through each log group and delete it
foreach (var logGroup in logGroups)
{
// Get a list of all streams in the log group
var logStreamsResponse = client.DescribeLogStreamsAsync(new DescribeLogStreamsRequest
{
LogGroupName = logGroup.LogGroupName
}).Result;
var logStreams = logStreamsResponse.LogStreams;
// Iterate through each stream and delete it
foreach (var logStream in logStreams)
{
client.DeleteLogStreamAsync(new DeleteLogStreamRequest
{
LogGroupName = logGroup.LogGroupName,
LogStreamName = logStream.LogStreamName
});
Thread.Sleep(TimeSpan.FromMilliseconds(50));
Console.WriteLine("Deleted log stream: " + logStream.LogStreamName + " in log group: " + logGroup.LogGroupName);
}
client.DeleteLogGroupAsync(new DeleteLogGroupRequest
{
LogGroupName = logGroup.LogGroupName
});
Thread.Sleep(TimeSpan.FromMilliseconds(50));
Console.WriteLine("Deleted log group: " + logGroup.LogGroupName);
}
Console.WriteLine("Deleted all log groups and streams in region: " + region.SystemName);
}
catch (AmazonCloudWatchLogsException e)
{
Console.WriteLine("Error while processing region " + region.SystemName);
Console.WriteLine("Caught Exception: " + e.Message);
Console.WriteLine("Response Status Code: " + e.StatusCode);
Console.WriteLine("Error Code: " + e.ErrorCode);
Console.WriteLine("Error Type: " + e.ErrorType);
Console.WriteLine("Request ID: " + e.RequestId);
}
}
}
}
Hope this helps someone!
Comparing #AWS S3 Upload via CLI to #Azure Blob upload via CLI.

The AWS Command Line Interface (CLI) is a unified tool to manage AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.
The Azure Command-Line Interface (CLI) is a set of commands used to create and manage Azure resources. It is available on Windows, macOS, and Linux.
Both the AWS CLI and Azure CLI allow you to manage cloud resources from the command line and automate them through scripts. However, there are some key differences to be aware of:
- Services: AWS offers a wider range of services, but Azure has some services that AWS does not, such as Azure Arc for managing hybrid environments.
- Language support: The AWS CLI supports multiple programming languages, including Python, Node.js, and C#. The Azure CLI is written in Node.js and is designed to be used with the Azure Resource Manager.
- Installation and setup: The AWS CLI is installed using a package manager or by downloading a standalone binary. The Azure CLI is installed using a package manager or by downloading the installer.
Overall, both the AWS CLI and Azure CLI are powerful tools that allow you to manage and automate your cloud resources. It really comes down to which cloud platform you are using and which services you need to manage.
Both the AWS and Azure CLI make it easy to upload files, but lets take a look at the difference
To login you type AWS Configure for AWS or AZ login for azure. the AZ login opens a browser so you can provide your credentials, whereas AWS Configure prompts for a IAM user key and secret. In my opinion, AZ makes this process easier for a first time user, but AWS tends to guide you towards the principle of least access better, so more secure for the novice user.
AWS arranges it’s S3 storage into buckets, and optionally folders within the buckets. Azure has storage accounts, and you must have at least one container within the storage account.
To upload a file on Azure it’s
az storage blob upload -f backup.zip -c database-backups –account-name backupaccount
And the same on AWS is:
aws s3 cp backup.zip s3://backupaccount/
Some complexities I had found with both Azure and AWS, is if you have multiple accounts, or subscriptions. In Azure, you have to select your subscription as follows;
az account set –subscription “PayAsYouGo”
Wheras, you can have multiple profiles in AWS, and that is selected using
aws s3 cp backup.zip s3://backupaccount/ –profile AWS
U2FsdGVkX1 and #AES – Why you should never use #CryptoJS

If you’re googling the term “U2FsdGVkX1” then you’re looking at some Base64 encoded AES encrypted text? How do I know that, becuase it decodes to “Salted__” – It’s the default value of the first few bytes in a block cypher.
AES (Advanced Encryption Standard) is a symmetric encryption algorithm that is widely used to secure data transmitted over the internet and to store data in encrypted form. One common way to use AES is to encrypt a message with a secret key, which can then be decrypted using the same key.
The “Salted__” prefix that sometimes appears at the beginning of AES-encrypted text is related to a technique called salting, which is used to make it more difficult to attack the encrypted data.
When a message is salted, a random sequence of bits (called a salt) is generated and appended to the message before it is encrypted. The salt is then stored along with the encrypted message, so that it can be used to reconstruct the original message when it is decrypted.
The purpose of salting is to add an extra layer of security to the encryption process by making it more difficult for an attacker to use precomputed tables or other techniques to try to break the encryption. For example, if an attacker knows that a particular message is encrypted with AES, they may be able to use a precomputed table of common words and phrases to try to guess the key and decrypt the message. However, if the message has been salted, the attacker will not be able to use the same precomputed table, because the salt will have changed the encrypted message in a way that is not predictable.
The “Salted__” prefix is added to the beginning of the encrypted message to indicate that the message has been salted, and to provide a place to store the salt. The prefix is followed by the salt itself, which is typically 8 bytes (64 bits) long. The rest of the encrypted message follows the salt.
In summary, the “Salted__” prefix is added to AES-encrypted text to indicate that the message has been salted, and to store the salt used in the salting process. Salting is used to add an extra layer of security to the encryption process by making it more difficult for an attacker to use precomputed tables or other techniques to try to break the encryption.
Beyond the theory, the text U2FsdGVkX1 can indicate the cypher mechanism used, which points an attacker towards AES. AES by itelf is very secure, but implementations of it can be very weak. I would immediately point the finger at CryptoJS. If you are using this in your webpage, you have just added a speedbump to a would-be attacker, nothing more than a paperclip holding your door closed. AES is secure, but it’s symetric, so therefore the client needs to know the key in order to encrypt the data. If you share your key on the page, and your browser can read it, then so can an attacker.
In fact, CryptoJS is such a bad idea, it gives a false sense of security. Is a padlock secure, yes. Is a Padlock with the key left in it still secure? Absolutely not.
Poland Vehicle License plate search now available via #API

Today, we have just launched our Vehicle License plate lookup API for poland, available here: https://www.tablicarejestracyjnaapi.pl/
The license plate lookup API for Poland is a tool that enables users to retrieve vehicle information from the Polish vehicle registry by providing the license plate number. This API allows users to access accurate and up-to-date information about vehicles registered in Poland, including details such as the make and model of the vehicle, the year it was manufactured, and the vehicle identification number (VIN).
The license plate lookup API for Poland is easy to use and can be integrated into a wide variety of applications. For example, it can be used by insurance companies to verify the details of a vehicle, or by car rental companies to ensure that the vehicles they are renting out are properly registered. Additionally, the API can be used by law enforcement agencies to quickly and easily obtain information about vehicles that may be involved in a crime.
Overall, the license plate lookup API for Poland is a valuable tool for anyone who needs to access vehicle information in Poland. It is fast, accurate, and easy to use, and can help users save time and improve the accuracy of their vehicle-related operations.
Poland support
Car registration plates in Poland use the /CheckPoland endpoint and return the following information:
- Make / Model
- Year
- VIN
- Engine Size
- Power
- Fuel
- Weight
- Region
- Representative image
Sample Registration Number:
EL6574U
Sample Json:
{
"Description": "SAAB 9-3",
"RegistrationDate": "2002-06-04",
"RegistrationYear": 2002,
"CarMake": {
"CurrentTextValue": "SAAB"
},
"CarModel": {
"CurrentTextValue": "9-3"
},
"MakeDescription": {
"CurrentTextValue": "SAAB"
},
"ModelDescription": {
"CurrentTextValue": "9-3"
},
"VehicleIdentificationNumber": "YS3DD55C622039715",
"EngineSize": 1985,
"Power": 110,
"FuelType": "Petrol",
"IsPlugIn": "False",
"SteeringWheelSide": "L",
"ManufacturingYear": 2002,
"Mileage": 175102,
"Weight": "1.9",
"Region": "Łódź",
"ImageUrl": "http://tablicarejestracyjnaapi.pl/image.aspx/@U0FBQiA5LTM="
}
Running a scheduled task on #AWS – A workaround for the 15 minute #Lambda limit

Let’s start with a bit of context. You want to run a process every day that could last 30 minutes, perhaps you’re importing data from an external source to a database. You can’t use Lambda, because the limit is 15 minutes, and it’s wasteful to use an EC2 instance because for 99% of the time the server will sit idle.
So, containers to the rescue. This is where you firstly write your code, and containerize it. Make sure it runs locally, as expected. Then you push the docker image to ECR. I followed most of the steps in this blog post:
https://towardsdatascience.com/deploying-a-docker-container-with-ecs-and-fargate-7b0cbc9cd608
The difference being, in my case, the application had a finite run time – i.e. do a task, then exit (not a web server).
Which means, that after I created my task definition, I then went to the Scheduled Task tab as shown below;

Where I could create a scheduled task that I can set to run every day, or minute, or whatever you need (the minium is 1 minute).
The container will run until it has finished it’s workload, so there is no 15 minute limit, like on AWS lambda.
Format prices correctly in #MSSQL using currencies in #ISO4127 format.
If you want to specify a price including a currency, you can always write EUR 1,234 or USD 1,234, but it’s more concise to write $1,234 or €1,234, and users expect that format. You can always handle this at application layer, but here’s how to do it at Database layer.
Here, I’ve created a table of the currencies I needed, – it’s not complete, and I hope that someone can post a link to a complete table.
create table CurrencyLocales
(
id int identity(1,1),
currency varchar(3),
locale varchar(5)
)
insert into CurrencyLocales (currency,locale) values ('AUD','en-AU')
insert into CurrencyLocales (currency,locale) values ('BRL','pt-BR')
insert into CurrencyLocales (currency,locale) values ('CAD','en-CA')
insert into CurrencyLocales (currency,locale) values ('CZK','cs-CZ')
insert into CurrencyLocales (currency,locale) values ('DKK','da-DK')
insert into CurrencyLocales (currency,locale) values ('EUR','en-IE')
insert into CurrencyLocales (currency,locale) values ('GBP','en-GB')
insert into CurrencyLocales (currency,locale) values ('HUF','hu-HU')
insert into CurrencyLocales (currency,locale) values ('MXN','es-MX')
insert into CurrencyLocales (currency,locale) values ('MYR','en-MY')
insert into CurrencyLocales (currency,locale) values ('NOK','nb-NO')
insert into CurrencyLocales (currency,locale) values ('NZD','en-NZ')
insert into CurrencyLocales (currency,locale) values ('RUB','ru-RU')
insert into CurrencyLocales (currency,locale) values ('SEK','sv-SE')
insert into CurrencyLocales (currency,locale) values ('SGD','en-SG')
insert into CurrencyLocales (currency,locale) values ('USD','en-US')
create index idxCurrency on CurrencyLocales(currency)
-- example
select *, FORMAT(1234, 'C', locale) as formattedPrice from CurrencyLocales
| id | Currency | Locale | Formatted |
| 1 | AUD | en-AU | $1,234.00 |
| 2 | BRL | pt-BR | R$1.234,00 |
| 3 | CAD | en-CA | $1,234.00 |
| 4 | CZK | cs-CZ | 1 234,00 Kč |
| 5 | DKK | da-DK | 1.234,00 kr. |
| 6 | EUR | en-IE | €1,234.00 |
| 7 | GBP | en-GB | £1,234.00 |
| 8 | HUF | hu-HU | 1 234,00 Ft |
| 9 | MXN | es-MX | $1,234.00 |
| 10 | MYR | en-MY | RM1,234.00 |
| 11 | NOK | nb-NO | kr 1 234,00 |
| 12 | NZD | en-NZ | $1,234.00 |
| 13 | RUB | ru-RU | 1 234,00 ₽ |
| 14 | SEK | sv-SE | 1.234,00 kr |
| 15 | SGD | en-SG | $1,234.00 |
| 16 | USD | en-US | $1,234.00 |
Runing Hosted CapMonster Locally in C#

If you use CapMonster Cloud, then you may find that the per-request pricing does add up over high volumes, if you have spare computing power, then you can run CapMonster Hosted on your own server., or if you are running a batch-process on your own local PC, then this could be a big cost saver.
It’s not free, since you need to buy a license from CapMonster for the base sofware, I used the Lite version for $37, available here: https://zennolab.com/en/products/capmonster/#section_price – Then you also need the sitekey add on, which is $10 per month, available here; https://zennolab.com/wiki/en:addons:capmonster:sitekey – But this now allows you solve 100,000 captchas per day, instead of the $0.6 * 100 = $60 per day cost of the equivalent on CapMonster Cloud at the same volume.
So, After downloading the required software, it will start a server on 127.0.0.3 (port 80) by default that exposes the same API as capmonster.cloud – but obviously with a differnt endpoint (local vs remote).
The problem is that if you use the NuGet Package here; https://www.nuget.org/packages/CapMonsterCloud then you will notice that this does not offer the API endpoint to be configurable.
What I did was clone the repo from https://github.com/mboukhlouf/CapMonsterCloud and then set then change the ApiBaseUrl specified in Endpoints.cs – or make it a public property, and modify it in your client code.
So, this could be a good cost saving tip, for heavy users of CapMonster.
Using AWS CloudFront as a proxy

Typically, CloudFront is used to serve your own website, so that it can leverage AWS’s CDN, and various edge servers in many countries, so that data is not transferred accross the world with every HTTP request.
But, you can also use it as a proxy, by pointing CloudFront at someone else’s website. This means that when you visit the CloudFront URL, the request to the third party website will come from AWS rather than from your local machine.
It’s not as anonymous as a good proxy, since there are various headers that would undoubtedly expose you, based on the request made to HTTPBIN below;
{
"args": {},
"headers": {
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-US,en;q=0.9",
"Dnt": "1",
"Host": "httpbin.org",
"Sec-Ch-Ua": "\"Google Chrome\";v=\"107\", \"Chromium\";v=\"107\", \"Not=A?Brand\";v=\"24\"",
"Sec-Ch-Ua-Mobile": "?0",
"Sec-Ch-Ua-Platform": "\"Windows\"",
"Sec-Fetch-Dest": "document",
"Sec-Fetch-Mode": "navigate",
"Sec-Fetch-Site": "none",
"Sec-Fetch-User": "?1",
"Upgrade-Insecure-Requests": "1",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36",
"X-Amzn-Trace-Id": "Root=1-636908d7-xxxxxxxx"
},
"origin": "xxx.xxx.xxx.xxx",
"url": "https://httpbin.org/get"
}
Here X-Amzn-Trace-Id could probably be tied to you.
Extract Assemblies.blob / Assemblies.manifest from Xamarin APK

When unzipping a Xamarin-built APK, you may notice that in the \assemblies folder there are no longer a list of DLLS, but two files, Assemblies.blob and Assemblies.manifest, where the manifest contains a list of filenames, and their associated Hashes, and the blob file contains the compressed data. All this gives the APK a smaller footprint on device. (Even though the APK is zipped anyway, but I presume that someone has done the maths!)
To uncompress the Assemblies.blob file, you’ll need python installed on your machine – and clone the repo from https://github.com/jakev/xamarin-assembly-store-unpack/blob/master/unpack-store.py
With this script, you can decompress the assemblies.blob / manifest using the syntax;
usage: unpack-store.py [-h] [–blob BLOB] [–manifest MANIFEST]
After this, you have a load of Lz4 files. You pick the file you’re interested in, and then git clone the repo
https://github.com/infiniteloopltd/lz4_decompress
Then using this script, you then run the command;
python lz4_decompress.py [filename].lz4
Which gives you the DLL that you can import into dotnetpeek or ILSpy.