Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-65555

Plugin does not work with withCredentials

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • http-request-plugin
    • None
    • Http Request plugin v1.9.0
      Jenkins 2.277.3

      When I am using the plugin like below, it works fine:

      httpRequest customHeaders: [[name: 'Authorization', value: "Token harcodedtokenvaluehere"], [name: 'accept', value: "application/vnd.github.v3+json"]], httpMode: 'POST', requestBody: '{"head":"head","base":"base"}', url: "myurl"

      But when I try to use withCredentials to pass Token value through Jenkins credentials, job fails with Response Code: HTTP/1.1 401 Unauthorized.

      withCredentials([string(credentialsId: 'githubToken', variable: 'TOKEN')]) {

         httpRequest customHeaders: [[name: 'Authorization', value: "Token %TOKEN%"], [name: 'accept', value: "application/vnd.github.v3+json"]], httpMode: 'POST', requestBody: '

      {"head":"head","base":"base"}

      ', url: "myurl"

      }

            janario Janario Oliveira
            richmond Rich
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: