Issue
When trying to make a connection back to the Contrast UI using the SDK, the following error is thrown:
java.io.IOException: Server returned HTTP response code: 401 for URL:
https://app.contrastsecurity.com/Contrast/unauthorized.html
Cause
When attempting to create an instance of the Contrast SDK, this exception may be thrown if the username, API key or service key you provided are incorrect. If you catch the thrown IOException and continue to make use of that instance of the Contrast SDK object, additional IOExceptions will be thrown.
Another cause of these exceptions is if your user account does not have the appropriate permissions within the Contrast UI. For instance, a user with only View permissions in Contrast will not be able to edit or perform administrative actions through the SDK.
Resolution
Make sure the authentication values are being provided and that the user has the appropriate permissions within the Contrast UI.