This issue is archived. You can view it, but you can't modify it. Learn more

ExportXMLWordPrintable

      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:

       

            Assignee:
            Janario Oliveira
            Reporter:
            Haroldo Carvalho
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Archived: