Genesys CTI User Forum
		Genesys CTI User Forum => Genesys CTI Technical Discussion => Topic started by: dubsky on May 30, 2023, 04:51:04 PM
		
			
			- 
				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 
			 
			
			- 
				In composer you have a block specifically for that. Check the basic help from composer
Enviado de meu SM-N9600 usando o Tapatalk
			 
			
			- 
				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 = {
    "msisdn": "852369",
    "segment": "HVC"
};
Thanks