HTTP error code 415 almost always indicates a Content-Type problem, not an authentication issue.
In your code, you're using "text/plain" but you're using JSON.
It's likely that the server expects application/json, or a specific type defined by the API (for example, application/octet-stream, application/encrypted+json, etc.).