jenkinsci / jenkinsci/http-request-plugin
[JENKINS-65555] Plugin does not work with withCredentials
- 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
janario
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
Assessment
This issue has not been assessed yet.