jenkinsci / jenkinsci/http-request-plugin

[JENKINS-65555] Plugin does not work with withCredentials

Open
#302 1 comment 0 reactions 0 assignees View on GitHub
component:http-request-plugin imported-jira-issue priority:major resolution:unresolved
Dominant language
Java
Stars
176
Forks
158
Avg merge
1d 16h
Merged PRs (30d)
3

Description

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"

}

---
Originally reported by richmond, imported from: Plugin does not work with withCredentials


  • assignee: janario
  • status: Open
  • priority: Major
  • component(s): http-request-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 3
  • imported: 20260702-081740

Raw content of original issue

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"

}

environment

```
Http Request plugin v1.9.0

Jenkins 2.277.3
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.