jenkinsci / jenkinsci/http-request-plugin

[JENKINS-58966] httprequest plugin response does not include content in case http request fails with error 500

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

Description

Code below is using 'validResponseCodes' to prevent http request to throw exception in case service returns error 500.

def cusHeader = [[name: 'Content-Type', value: 'application/json; charset=utf-8'],[name: 'Accept-Charset', value: 'utf-8']] 

def payload = "{\"body\":{\"ProcessName\":\"Generic Process\"}}"

def response = httpRequest timeout: 60, authentication: "${JENKINS_APP_CRED}", customHeaders: cusHeader, httpMode: 'POST', requestBody: payload, url: "http://${rest_serv}:9001/RunProcess", validResponseCodes: '100:500'

println response


 

Although we get along with code 500 a json with error message, it is not included in response from httprequest as we can see below:

Result from curl:

Result from httprequest:

 

---
Originally reported by haroldo_bonette, imported from: httprequest plugin response does not include content in case http request fails with error 500


  • assignee: janario
  • status: Open
  • priority: Minor
  • component(s): http-request-plugin
  • label(s): content, http-request, response
  • resolution: Unresolved
  • votes: 0
  • watchers: 1
  • imported: 20260702-081740

Raw content of original issue

Code below is using 'validResponseCodes' to prevent http request to throw exception in case service returns error 500.



def cusHeader = [[name: 'Content-Type', value: 'application/json; charset=utf-8'],[name: 'Accept-Charset', value: 'utf-8']] 

def payload = "{\"body\":{\"ProcessName\":\"Generic Process\"}}"

def response = httpRequest timeout: 60, authentication: "${JENKINS_APP_CRED}", customHeaders: cusHeader, httpMode: 'POST', requestBody: payload, url: "http://${rest_serv}:9001/RunProcess", validResponseCodes: '100:500'

println response



 

Although we get along with code 500 a json with error message, it is not included in response from httprequest as we can see below:

Result from curl:

Result from httprequest:

 

environment

```
Jenkins ver. 2.176.2

httprequest plugin 1.8.23
```

2 attachments

- [image-2019-08-16-15-16-35-520.png](https://raw.githubusercontent.com/jenkinsci/attachments-from-jira-issues-misc/refs/heads/main/attachments/48345/image-2019-08-16-15-16-35-520.png)
> ![image-2019-08-16-15-16-35-520.png](https://raw.githubusercontent.com/jenkinsci/attachments-from-jira-issues-misc/refs/heads/main/attachments/48345/image-2019-08-16-15-16-35-520.png)
- [image-2019-08-16-15-19-00-536.png](https://raw.githubusercontent.com/jenkinsci/attachments-from-jira-issues-misc/refs/heads/main/attachments/48344/image-2019-08-16-15-19-00-536.png)
> ![image-2019-08-16-15-19-00-536.png](https://raw.githubusercontent.com/jenkinsci/attachments-from-jira-issues-misc/refs/heads/main/attachments/48344/image-2019-08-16-15-19-00-536.png)

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.