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

9 views
Skip to first unread message

haroldo.bonette@gmail.com (JIRA)

unread,
Aug 16, 2019, 9:22:02 AM8/16/19
to jenkinsc...@googlegroups.com
Haroldo Carvalho created an issue
 
Jenkins / Bug JENKINS-58966
httprequest plugin response does not include content in case http request fails with error 500
Issue Type: Bug Bug
Assignee: Janario Oliveira
Attachments: image-2019-08-16-15-16-35-520.png, image-2019-08-16-15-19-00-536.png
Components: http-request-plugin
Created: 2019-08-16 13:21
Labels: http-request content response
Priority: Minor Minor
Reporter: Haroldo Carvalho

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 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:

 

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

haroldo.bonette@gmail.com (JIRA)

unread,
Aug 16, 2019, 9:23:01 AM8/16/19
to jenkinsc...@googlegroups.com
Haroldo Carvalho updated an issue
Change By: Haroldo Carvalho
Code below is using 'validResponseCodes' to prevent http request to throw exception in case service returns error 500.
{code:java}

def cusHeader = [[name: 'Content-Type', value: 'application/json; charset=utf-8'],[name: 'Accept-Charset', value: 'utf-8']]
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{code}

 

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:

!image-2019-08-16-15-19-00-536.png!

Result from httprequest:

!image-2019-08-16-15-16-35-520.png!

 

haroldo.bonette@gmail.com (JIRA)

unread,
Aug 16, 2019, 9:28:04 AM8/16/19
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages