<?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: Internal Server Error occurs while passing string to SetBody() in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443276#M4659865</link>
    <description>&lt;P&gt;Thanks Morten, little embarrassed &lt;A href="https://emojipedia.org/grinning-face-with-sweat/"&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;&lt;/A&gt; myself about that silly mistake. &lt;/P&gt;&lt;P&gt;However, Is there any way to check the syntax to avoid such mistakes in future.&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Senz.&lt;/P&gt;</description>
    <pubDate>Sat, 05 Jun 2021 16:56:46 GMT</pubDate>
    <dc:creator>former_member187312</dc:creator>
    <dc:date>2021-06-05T16:56:46Z</dc:date>
    <item>
      <title>Internal Server Error occurs while passing string to SetBody()</title>
      <link>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaq-p/12443273</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
  &lt;P&gt;I'm trying to build an xml body using groovy script from different sender. I could build xml file and convert to string, same way I could test in IntelliJ without an issue. when I deploy the same code in CPI, I'm getting the below Error.&lt;/P&gt;
  &lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;com.sap.it.rt.adapter.http.api.exception.HttpResponseException: An internal server error occured: No signature of method: com.sap.gateway.ip.core.customdev.processor.MessageImpl.SetBody() is applicable for argument types (java.lang.String) values: [&amp;lt;ProdCatalog&amp;gt;....&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1944496-7ssxb.png" /&gt;&lt;/P&gt;
  &lt;P&gt;Groovy Script&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import groovy.xml.MarkupBuilder
import groovy.xml.XmlSlurper


def Message processData(Message message) {
    //Body 
def body = message.getBody();

def root = new XmlSlurper().parseText(body)
def writer = new StringWriter()
def builder = new MarkupBuilder(writer)

builder.ProdCatalog {
    'ArrayOfPCatInfo' {
        root.Root.each { item -&amp;gt;
            'PCatInfo' {
                'PFC'(item.PFCCode)
                'PF'(item.ProductFamily)
                'S'(item.Security)
                'PC'(item.TFSProductID)
                'P'(item.ProductDescription)
            }
        }
    }
    'ArrayOfPCatVersion' {
        root.Root.Version.Version.Package.Package.Module.Module.each { item -&amp;gt;
            'PCatVersion' {
                'PC'(item.parent().parent().parent().parent().parent().parent().TFSProductID)
                'VC'(item.parent().parent().parent().parent().VersionCode)
                'VC'(item.parent().parent().parent().parent().VersionDescription)
                'PKC'(item.parent().parent().PackageCode)
                'PK'(item.parent().parent().PackageDescription)
                'MC'(item.ModuleCode)
                'M'(item.ModuleDescription)
            }
            //println item.parent().parent().PackageDescription
        }
        root.Root.Version.Version.Package.Package.each { item -&amp;gt;
            if (item.Module.Module.size() &amp;lt;= 0) {
                'PCatVersion' {
                    'PC'(item.parent().parent().parent().parent().TFSProductID)
                    'VC'(item.parent().parent().VersionCode)
                    'VC'(item.parent().parent().VersionDescription)
                    'PKC'(item.PackageCode)
                    'PK'(item.PackageDescription)
                    'MC'("NULL")
                    'M'("NULL")
                }
            }
        }
        root.Root.Version.Version.each { item -&amp;gt;
            if (item.Package.Package.size() &amp;lt;= 0) {
                'PCatVersion' {
                    'PC'(item.parent().parent().TFSProductID)
                    'VC'(item.VersionCode)
                    'VC'(item.VersionDescription)
                    'PKC'("NULL")
                    'PK'("NULL")
                    'MC'("NULL")
                    'M'("NULL")
                }
            }
        }
    }
}
//    println("-----------------" + dc)
def op = writer.toString()
message.SetBody(op)

return message;
}
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;As I'm still in learning phase of CPI, any explanation/guidance/recommended approach along with solution would be much helpful&lt;/P&gt;
  &lt;P&gt;Thanks,&lt;/P&gt;
  &lt;P&gt;Senz&lt;/P&gt;</description>
      <pubDate>Sat, 05 Jun 2021 14:19:52 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaq-p/12443273</guid>
      <dc:creator>former_member187312</dc:creator>
      <dc:date>2021-06-05T14:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Server Error occurs while passing string to SetBody()</title>
      <link>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443274#M4659863</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;senz.evo&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;Hope you are doing well!&lt;/P&gt;&lt;P&gt; Could you please try message.setBody(op) ?&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;Pavan&lt;/P&gt;</description>
      <pubDate>Sat, 05 Jun 2021 15:08:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443274#M4659863</guid>
      <dc:creator>babruvahana</dc:creator>
      <dc:date>2021-06-05T15:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Server Error occurs while passing string to SetBody()</title>
      <link>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443275#M4659864</link>
      <description>&lt;P&gt;Hi there&lt;/P&gt;&lt;P&gt;You are calling SetBody with an uppercase "S"; the correct method name is setBody with a lowercase "s".&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Morten&lt;/P&gt;</description>
      <pubDate>Sat, 05 Jun 2021 15:52:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443275#M4659864</guid>
      <dc:creator>MortenWittrock</dc:creator>
      <dc:date>2021-06-05T15:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Server Error occurs while passing string to SetBody()</title>
      <link>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443276#M4659865</link>
      <description>&lt;P&gt;Thanks Morten, little embarrassed &lt;A href="https://emojipedia.org/grinning-face-with-sweat/"&gt;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;&lt;/A&gt; myself about that silly mistake. &lt;/P&gt;&lt;P&gt;However, Is there any way to check the syntax to avoid such mistakes in future.&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Senz.&lt;/P&gt;</description>
      <pubDate>Sat, 05 Jun 2021 16:56:46 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443276#M4659865</guid>
      <dc:creator>former_member187312</dc:creator>
      <dc:date>2021-06-05T16:56:46Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Server Error occurs while passing string to SetBody()</title>
      <link>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443277#M4659866</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="mention-scrubbed"&gt;senz.evo&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;No worries - we all make mistakes. This one is hard to catch before the script actually runs, though. As you already learned, the editor doesn't check or compile the code. But look on the bright side: Now you know how to spot this error, should it happen again &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Have fun with CPI!&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Morten&lt;/P&gt;</description>
      <pubDate>Sat, 05 Jun 2021 17:10:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443277#M4659866</guid>
      <dc:creator>MortenWittrock</dc:creator>
      <dc:date>2021-06-05T17:10:25Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Server Error occurs while passing string to SetBody()</title>
      <link>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443278#M4659867</link>
      <description>&lt;P&gt;Hi Morten,&lt;/P&gt;&lt;P&gt;Just found out a blog that I'm looking for.&lt;/P&gt;&lt;P&gt;&lt;A href="https://blogs.sap.com/2020/04/06/faster-groovy-development-for-sap-cpi-without-installing-an-ide/" target="test_blank"&gt;https://blogs.sap.com/2020/04/06/faster-groovy-development-for-sap-cpi-without-installing-an-ide/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Cool,&lt;/P&gt;&lt;P&gt;Senz&lt;/P&gt;</description>
      <pubDate>Sat, 05 Jun 2021 17:16:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443278#M4659867</guid>
      <dc:creator>former_member187312</dc:creator>
      <dc:date>2021-06-05T17:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Server Error occurs while passing string to SetBody()</title>
      <link>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443279#M4659868</link>
      <description>&lt;P&gt;Hello again &lt;SPAN class="mention-scrubbed"&gt;senz.evo&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;Ah yes, that's true. Nice find.&lt;/P&gt;&lt;P&gt;Another shortcut is to use the simulation mode to run the script step. That will execute the code, without you having to deploy the entire iflow and call it from somewhere like PostMan.&lt;/P&gt;&lt;P&gt;If you haven't played with the simulation mode yet, take this opportunity to try it out. It's a really useful way to test your work while you are building the iflow.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Morten&lt;/P&gt;</description>
      <pubDate>Sat, 05 Jun 2021 17:23:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443279#M4659868</guid>
      <dc:creator>MortenWittrock</dc:creator>
      <dc:date>2021-06-05T17:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: Internal Server Error occurs while passing string to SetBody()</title>
      <link>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443280#M4659869</link>
      <description>&lt;P&gt;Thanks a lot Morten, I'm fired up &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Sat, 05 Jun 2021 17:33:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/internal-server-error-occurs-while-passing-string-to-setbody/qaa-p/12443280#M4659869</guid>
      <dc:creator>former_member187312</dc:creator>
      <dc:date>2021-06-05T17:33:54Z</dc:date>
    </item>
  </channel>
</rss>

