Search code examples
javascriptauthenticationjenkinshudsonapi-key

Jenkins/Hudson API Access with API Key Not Working


I'm trying to access my Jenkins build though the api however am unsure whether it is possible to do with a straight forward URL.

I've basically built a local website in which I have something like:

var jsonAPI = "http://jenkinsurl.com/build/api/json"

However I need authenticated. So i found my API Token but how do I put it together - is it like:

var jsonAPI = "http://jenkinsurl.com/build/api/json?apitoken=xxxxxxx"

Thanks


Solution

  • API Token is basically like a password. You still need to supply a username/password pair at HTTP authentication.

    You can try (replace apitoken with actual token):
    http://username:apitoken@jenkinsurl.com/build/api/json
    or with curl:
    curl -u username:apitoken http://jenkinsurl.com/build/api/json