Page 1 of 1

Get response body when using <data> and HTTP response != 2xx

Posted: Fri Dec 22, 2017 11:35 am
by srmoser430
Hi,

My app server uses HTTP response codes 5xx to indicate 'normal' application errors (e.g., missing request data, failed business rule, etc). In these cases, the HTTP response contains error data that I'd like to use in the VXML script.

Can I get access to the HTTP document response data (JSON data) when the HTTP response code is 5xx?

Thanks...Scot

Re: Get response body when using <data> and HTTP response !=

Posted: Fri Dec 22, 2017 12:45 pm
by support
Hi Scot,

You can capture HTTP error codes by using the <catch> tag. Here's an example snippet of VoiceXML:

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0">
   <form>
      <block>
         <prompt>
            gonna go to a badfetch page
         </prompt>
         <goto next="http://pagethatreturns5xx.com"/>
      </block>
      <catch event="error.badfetch">
         <prompt>
            caught a badfetch error <value expr="_event"/>
         </prompt>
      </catch>
   </form>
</vxml>
Your script can parse the contents "_event" variable that's set by the <catch> tag and branch accordingly.

Regards,
Plum Support

Re: Get response body when using <data> and HTTP response !=

Posted: Thu Jan 25, 2018 11:00 am
by srmoser430
Thanks. Can I get access to the response body as well? When my app responds with HTTP code 5xx there is additional error info within a JSON string contained in the response body.

Thanks...Scott

Re: Get response body when using <data> and HTTP response !=

Posted: Thu Jan 25, 2018 1:49 pm
by support
Hi Scott,

There are no facilities that allow access to the response body. You can, however, differentiate between different error codes by specifying more granular catch event strings. So, for instance, if you have <catch> blocks for "error.badfetch" and "error.badfetch.503", if an HTTP 503 were to be thrown, the latter block would be the one executed as the matching string is longer.

Regards,
Plum Support

Re: Get response body when using <data> and HTTP response !=

Posted: Fri Jan 26, 2018 8:28 am
by srmoser430
Ok - thanks. Are there plans to add this feature? If not, how do I submit an enhancement request?

Re: Get response body when using <data> and HTTP response !=

Posted: Fri Jan 26, 2018 10:00 am
by support
Hi,

There are no current plans to add this capability but we are always happy to collect feature requests from our customers and have even, on occasion, implemented some of those requests. Thanks for trying to make our products better!

Regards,
Plum Support