We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

Pass Custom Http Headers to Rest API thru VoiceXml

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
sachinc
Posts: 2
Joined: Thu Feb 11, 2016 10:45 pm

Pass Custom Http Headers to Rest API thru VoiceXml

Post by sachinc »

Hi,
I'm trying yo pass Pass Custom Http Headers to Rest API thru voice xml as below. But im getting error because the http headers
are not passed to the api correctly. But it's working as expected in Plumfuse. Please guide me how can i pass Custom Http Headers to Rest API
using below code.

HTTP/1.1 401 Unauthorized - https://test.abc.com/v1/Session
DocumentParser::FetchBuffer - could not open URL: https://test.abc.com/v1/Session
DocumentParser::FetchDocument - exiting with error result 2
errno: 203 uri https://test.abc.com/v1/Session

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
  <form>
    <subdialog name="result" method="post" fetchtimeout="10s" src="https://test.abc.com/v1/Session">
    <param name="Key" expr="'1234GY7890'"/> 
    <param name="Device" expr="'testdevice'"/>
    <param name="Content-Length" expr="'0'"/>
      <filled>
        Your session is <value expr="result"/>.
      </filled>
    </subdialog>
  </form>
</vxml>

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: Pass Custom Http Headers to Rest API thru VoiceXml

Post by support »

Hi,

Native vxml does not support http headers. This is not included in the vxml specification for tags like subdialog, submit, and data. Normally, we would submit to a script in a higher level language in which you could make the request via cURL or something along those lines. Something like the following, where the script at http://example.com/some_script.php would have the credentials available in order to make that request.

Code: Select all

<form id="validate_account">
	<subdialog name="valid_account" src="http://example.com/some_script.php" namelist="acct_num zip" method="post" fetchtimeout="60s"/>
	<block>
		<if cond="valid_account.status == 'valid'">
			<!-- do something -->
		<elseif cond="valid_account.status == 'invalid'"/>
			<!-- do something else -->
		</if>
	</block>
</form>
In this sample, you can submit variables captured in your call to that remote script, and then set the headers in you higher level language to make that request. Kind of like a wrapper script to call that remote script with the proper credentials.

Hopefully that helps. Please let us know if you have any additional questions.

Regards,
Plum Support

Post Reply