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

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

  • Author
  • Message
Offline

srmoser430

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

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

PostFri Dec 22, 2017 11:35 am

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
Offline

support

  • Posts: 3505
  • Joined: Mon Jun 02, 2003 3:47 pm
  • Location: Boston, MA

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

PostFri Dec 22, 2017 12:45 pm

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
Offline

srmoser430

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

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

PostThu Jan 25, 2018 11:00 am

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
Offline

support

  • Posts: 3505
  • Joined: Mon Jun 02, 2003 3:47 pm
  • Location: Boston, MA

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

PostThu Jan 25, 2018 1:49 pm

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
Offline

srmoser430

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

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

PostFri Jan 26, 2018 8:28 am

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

support

  • Posts: 3505
  • Joined: Mon Jun 02, 2003 3:47 pm
  • Location: Boston, MA

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

PostFri Jan 26, 2018 10:00 am

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

Return to Plum DEV Q&A

Who is online

Users browsing this forum: No registered users and 1 guest

cron