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

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

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
srmoser430
Posts: 20
Joined: Thu Oct 19, 2017 3:40 pm

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

Post 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

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

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

Post 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

srmoser430
Posts: 20
Joined: Thu Oct 19, 2017 3:40 pm

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

Post 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

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

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

Post 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

srmoser430
Posts: 20
Joined: Thu Oct 19, 2017 3:40 pm

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

Post by srmoser430 »

Ok - thanks. Are there plans to add this feature? If not, how do I submit an enhancement request?

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

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

Post 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

Post Reply