Reputation: 41
I am using the Http Request plugin in Jenkins to run HTTP Request towards an API.
I need to use a token for the authorization. So I configured on Jenkins global configuration a secret text credential with the token and gave it the id segron.
Then I run the API Call in Jenkins like this
httpRequest url: "http://10.10.10.10:8080/api/run/", httpMode: 'POST', contentType:'APPLICATION_JSON',authentication: 'segron'
.
But when I run the pipeline I got this error.
java.lang.IllegalStateException: Authentication 'segron' doesn't exist anymore
I use the same plugin to run other API Call using username / password as credentials, and it works perfectly fine.
Any help/experience regarding this?
Upvotes: 2
Views: 2008
Reputation: 133
I had a similar issue. In my case the Http Request plugin did not like the API-token stored as "secret text" in Jenkins.
After changing it to a username/password credential type it worked for me.
This is a bit unexpected as Bitbucket related APIs like notfiyBitbucket worked perfectly fine with API-token in secret text credentials, but Http Request plugin does not seem to support that. It does work the other way around though, notifyBitbucket also works with username/password credential type, so no need to store the API token twice now.
I assume this is the place where the exception is thrown: https://github.com/jenkinsci/http-request-plugin/blob/master/src/main/java/jenkins/plugins/http_request/HttpRequestExecution.java#L239 Looking at the lines above that, only a limited set of credential types seem to be supported. The exception should probably at least emit a more descriptive error message to understand what is wrong.
Upvotes: 1