When trying to use REST API through a GEL script, I get Error 401 (Unauthorized). I use Knowledge Document 218785 as sample script.
The script is only a sample and the issue lies with the hardcoded value for Authorization header.
<core:arg value="Authorization" type="java.lang.String"/>
<core:arg value="Basic YWRtaW46YWRtaW4=" type="java.lang.String"/>
In the example the value is for username/password as admin/admin.
If you are not using SSO then you can navigate to any online Base64 encoder and encode the username and password in the format username:password. Note: the colon is also part of the string.
Once that's encoded replace the value and try again.
Also, ensure that the user is 'Active' (i.e.: not 'Locked' nor 'Inactive').
If you are using SSO then you will need to create an API key and use BEARER authentication to succeed.
The following documentation has more information about API Keys.