CSRF validation problem with web service

I have created a web service which is fully working. However, as soon as I enable CSRF validation in config/main.php I get an error when trying to use the web service saying:

I found a proposed solution at this link, but it’s not working for me and I’m not sure that the CSRF validation is actually enabled using this proposed solution.

The reason for doubting this is that the solution is never enabling the csrfvalidation by using this string:

Instead, the proposed solution is this:

Do you have any ideas about this?

It works as far as I’m concerned. But of course you have to implement (copy-paste) HttpRequest class. Personally I’ve followed these two posts: