" /> How to call REST API using composer VXML - Genesys CTI User Forum

Author Topic: How to call REST API using composer VXML  (Read 899 times)

Offline dubsky

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
How to call REST API using composer VXML
« on: May 30, 2023, 04:51:04 PM »
Advertisement
Hi There,

I want to know how to call REST API using Composer (VXML) project for the POST method with JSON data as input.

Thanks

Offline cavagnaro

  • Administrator
  • Hero Member
  • *****
  • Posts: 7641
  • Karma: 56330
Re: How to call REST API using composer VXML
« Reply #1 on: May 31, 2023, 07:03:31 PM »
In composer you have a block specifically for that. Check the basic help from composer

Enviado de meu SM-N9600 usando o Tapatalk


Offline dubsky

  • Newbie
  • *
  • Posts: 13
  • Karma: 0
Re: How to call REST API using composer VXML
« Reply #2 on: June 01, 2023, 09:38:31 AM »
I tried to use [b]Web Request [/b]block but got the below error in MCP log .

[color=red][color=green]Result of FIlter API HVC{"errorMsg":null,"throwServerException":false}
2023-05-29T16:17:35.350 DBUG 12F5FE47-10021D72 3634780480 0C000000 LogRuntime.cxx:192 Execute() Result [
Result of FIlter API HVC{"errorMsg":null,"throwServerException":false}
][/color][/color]

[color=green]please find the vxml code pieces for WebRequest block:[/color]

<form id="FilterAPI_for_HVC">
  <block>
<script>
    var requestObj = new Object();
requestObj['WebUrl'] = AppState.var_FilterAPI;
requestObj['Protocol'] = 'post';
requestObj['Enctype'] = 'application/x-www-form-urlencoded';
requestObj['VerifyJSON'] = true;
    requestObj['JsonContent'] = AppState.var_JSON_HVC;
requestObj['AuthenAccess'] = false;


            requestObj['Timeout'] = '90';
           
var customHeaders = new Object();

customHeaders['Accept'] = '*/*';
customHeaders['Connection'] = 'keep-alive';
customHeaders['Content-Type'] = 'application/json';
requestObj['CustomHeaders'] = customHeaders;
requestObj['enableProxy']=false;
requestObj['proxyHost']='';
requestObj['proxyPort']=80;
requestObj['proxyUserName']='';
requestObj['proxyPassword']='';
requestObj['SSLauthenticationType'] = 'Anonymous';
requestObj['SSLcertificateAlias'] = '';
requestObj['SSLKeyStoreLocation'] = '';
requestObj['SSLcertifcateStoreName'] = '';
requestObj['SSLkeyAlgorithm'] = 'DSA';
requestObj['SSLkeyStorePassword'] = '';
requestObj['SSLprivateKeyPassword'] = '';
</script>
<data name="FilterAPI_for_HVCResponse" enctype="application/json"
gvp:contentexpr="requestObj" method="post"
src="../include/getWebRequestData.jsp" />    
<if cond="typeof FilterAPI_for_HVCResponse.errorMsg == 'undefined'">
    <assign name="AppState.var_WebResult_HVCFilter" expr="FilterAPI_for_HVCResponse" />    
    <goto next="#Copy_1_Log2" />
<else/>
<if cond="FilterAPI_for_HVCResponse.throwServerException">
        <throw event="error.com.genesyslab.composer.servererror" messageexpr="FilterAPI_for_HVCResponse.errorMsg" />
        <else/>
    <assign name="AppState.var_WebResult_HVCFilter" expr="FilterAPI_for_HVCResponse" />    
    <goto next="#Copy_1_Log2" />
      </if>
        </if> 
  </block>

</form>

[color=green]I am passing Input as JSON data. Please find the below VXML code for that.[/color]

AppState.var_JSON_HVC = {
    &quot;msisdn&quot;: &quot;852369&quot;,
    &quot;segment&quot;: &quot;HVC&quot;
};


Thanks