<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: SAP CPI exception: getStatusCode() is applicable for argument types: () values: [] in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/sap-cpi-exception-getstatuscode-is-applicable-for-argument-types-values/qaa-p/12199873#M4564628</link>
    <description>&lt;P&gt;Hello Prabhu,&lt;/P&gt;&lt;P&gt;Please refer to below help document which is applicable for HTTP adapter.&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/a443efe1d5d2403fb95ee9def1a672d4.html" target="_blank"&gt;https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/a443efe1d5d2403fb95ee9def1a672d4.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;For open connector adapter you might need to white list all the headers in run time configuration and then check for the corresponding header which returning the error status code.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Regards,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Sriprasad Shivaram Bhat&lt;/P&gt;</description>
    <pubDate>Tue, 07 Apr 2020 15:37:30 GMT</pubDate>
    <dc:creator>Sriprasadsbhat</dc:creator>
    <dc:date>2020-04-07T15:37:30Z</dc:date>
    <item>
      <title>SAP CPI exception: getStatusCode() is applicable for argument types: () values: []</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cpi-exception-getstatuscode-is-applicable-for-argument-types-values/qaq-p/12199872</link>
      <description>&lt;P&gt;Dear All&lt;/P&gt;
  &lt;P&gt;I am trying to get the http status code when an exception is called. I think i have the right groovy in place but getting the below error:&lt;/P&gt;
  &lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;java.lang.NoSuchMethodException: No signature of method: com.sap.it.rt.adapter.openconnectors.exceptions.OpenConnectorsException.getStatusCode() is applicable for argument types: () values: []&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
  &lt;P&gt;The message properties:&lt;/P&gt;
  &lt;BR /&gt;CamelExceptionCaughtcom.sap.it.rt.adapter.openconnectors.exceptions.OpenConnectorsException: HTTP operation failed : {"requestId":"5e8c93f9e4b02c84ec1e41f4","message":"Service Unavailable","providerMessage":"error - {code=503, message=The service is currently unavailable., status=UNAVAILABLE}"} status code : 503
  &lt;P&gt;My code:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;    def map = message.getProperties();
    def ex = map.get("CamelExceptionCaught");
    
    if (ex!=null) {
     message.setHeader("HTTP_CODE", ex.getStatusCode());
    }
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Any help on this please?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 15:15:57 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cpi-exception-getstatuscode-is-applicable-for-argument-types-values/qaq-p/12199872</guid>
      <dc:creator>prabhu_s2</dc:creator>
      <dc:date>2020-04-07T15:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: SAP CPI exception: getStatusCode() is applicable for argument types: () values: []</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cpi-exception-getstatuscode-is-applicable-for-argument-types-values/qaa-p/12199873#M4564628</link>
      <description>&lt;P&gt;Hello Prabhu,&lt;/P&gt;&lt;P&gt;Please refer to below help document which is applicable for HTTP adapter.&lt;/P&gt;&lt;P&gt;&lt;A href="https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/a443efe1d5d2403fb95ee9def1a672d4.html" target="_blank"&gt;https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/a443efe1d5d2403fb95ee9def1a672d4.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;For open connector adapter you might need to white list all the headers in run time configuration and then check for the corresponding header which returning the error status code.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Regards,&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Sriprasad Shivaram Bhat&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 15:37:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cpi-exception-getstatuscode-is-applicable-for-argument-types-values/qaa-p/12199873#M4564628</guid>
      <dc:creator>Sriprasadsbhat</dc:creator>
      <dc:date>2020-04-07T15:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: SAP CPI exception: getStatusCode() is applicable for argument types: () values: []</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cpi-exception-getstatuscode-is-applicable-for-argument-types-values/qaa-p/12199874#M4564629</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;The property "CamelExceptionCaught" contains just any Exception caught by the IFlow. Those exceptions don't have to be escpecially of type "AhcOperationFailedException". (They only should inherit the Throwable class.) But the &lt;EM&gt;getStatusCode() &lt;/EM&gt;method is a method of the Exception class "AhcOperationFailedException". When looking at your post, we can see your exception caught is of another type. Escpecially it is of type "OpenConnectorsException". &lt;/P&gt;&lt;P&gt;This exception class has no "getStatusCode" method. But what methods does it provide? By using reflection (as shown &lt;A href="https://blogs.sap.com/2017/03/11/reflecting-on-the-message-class/"&gt;in this article&lt;/A&gt; by &lt;SPAN class="mention-scrubbed"&gt;7a519509aed84a2c9e6f627841825b5a&lt;/SPAN&gt;) we can see, that the OpenConnectorsException class only brings one own (not inherited) method, called "getMessage". So the only function you can call is getMethod() which returns a String. &lt;/P&gt;&lt;P&gt;Nevertheless from your input above, we can see that the error messages text indeed contains a status code. So the solution might be to call getMessage to get the error text and then parse it for the status code. &lt;/P&gt;&lt;P&gt;The following code is "dummy" code, written out of my head. So maybe you have to correct one or two things, but in general it should work like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;def map = message.getProperties()
def ex = map.get("CamelExceptionCaught")
    
if (ex!=null) {
  //Detect exception type&lt;BR /&gt;  def exType = ex.getClass().getCanonicalName()
  if (exType == "org.apache.camel.component.ahc.AhcOperationFailedException"){
    message.setHeader("HTTP_CODE", ex.getStatusCode())
  } else if (exType == "com.sap.it.rt.adapter.openconnectors.exceptions.OpenConnectorsException"){
    def statusCode = (ex.getMessage() =~ /status code ?: ?(\d{3})/)[0][1]
    message.setHeader("HTTP_CODE", statusCode)
  }
}&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Apr 2020 16:10:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cpi-exception-getstatuscode-is-applicable-for-argument-types-values/qaa-p/12199874#M4564629</guid>
      <dc:creator>r_herrmann</dc:creator>
      <dc:date>2020-04-07T16:10:52Z</dc:date>
    </item>
  </channel>
</rss>

