My Oracle Support Banner

How to send multiline string in Twilio post request from Application Composer (Doc ID 2921047.1)

Last updated on JANUARY 13, 2023

Applies to:

Oracle Fusion CX Sales Cloud Service - Version and later
Information in this document applies to any platform.


We have used Twilio third party service for SMS functionality.

In ApplicationComposer , we have registered Twilio rest API based on the below steps and used this WS to send SMS and message format is text format, so for line break we had used \n keyword but we are getting \\n in SMS  message instead of a new line:

1) Create a new "My first Twilio account" and get a new Account SID/AuthToken, URI  and MessagingServiceSid
2) Test in POSTMAN to get POST request/response JSON payload and use it in step 3
3) Register the WS with URI{{ACCOUNT_SID}}/Messages.json and name 「TwiliioSMS」
4) Create a global function and use the following groovy:
    def phonenumber = pn;
    def messageForMobile = msg;
    def response;
    def httpErrorResponse;
    def messagingServiceSid = "<messagingServiceSid> from step1";
    def conn = adf.webServices.TwiliioSMS;

    def headers = [:]
    def params = [:]

    headers.'Content-Type' = 'application/x-www-form-urlencoded'
    headers.'charset' = 'utf-8'
    conn.requestHTTPHeaders = headers

    def values = "&To="+phonenumber+'&Body='+messageForMobile+"&MessagingServiceSid=${messagingServiceSid}&";   //VERY IMPORTANT: need to add '&' at the end after MessagingServiceSid value

          response = conn.POST(params)    
          httpErrorResponse = response.statusCode;
       println(":::-->Response Error Message::: "+conn?.error_message+"HTTP Response Code:::" + conn?.statusCode + " :::httpErrorResponse:::"+ conn?.httpErrorResponse +":::TRY-CATCH-EXCEPTION:::" + e )
       httpErrorResponse = conn?.httpErrorResponse;

    return httpErrorResponse;



To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!

In this Document

My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.