Obviously WebUI.setEncryptedPassword() does not work for API/Web Service testing.
I can sympathize with you but I suppose you need to do it.
If I were to do your job, I would take the following approach:
- make a properties file where you write the credentials, Or any JSON text file would do.
- your test case (both for Web and for API/Web Service) reads the properties file, Your test case code should do everything to read the file (no KS built-in support).
(But in Groovy, reading a JSON file is quite easy! see The Apache Groovy programming language - Parsing and producing JSON. ) - git ignore the credentials file out of the source code repository