You can only access data that you have been given access rights to. See https://www.ecmwf.int/en/forecasts/accessing-forecasts.

If you try to access datasets that you have no access rights for, your request will fail. For more information go to What is ECMWF WebAPI.

There are also some MARS access restrictions in place for some particular datasets.