Error with POST request

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

  • Author
  • Message
Offline

wes@@@

  • Posts: 6
  • Joined: Tue Aug 07, 2018 4:25 pm

Error with POST request

PostTue Aug 07, 2018 4:32 pm

I have an application that I'm making a POST request to in order to send and store a recording of the call, but it keeps giving me errors. I have tested the application using postman and it works there, so the issue must lie with how I'm making the POST request in the IVR app. I have the flow as such (for testing): call begin -> call_recording begins -> prompt that says stuff -> call_recording ends -> POST request to my app with variables in the body set as id = session.id and file = call_recording.

As a side note, the post request returns nothing except a status and I've tried having the IVR's post return type as empty and text. Also, I see that you can handle errors some how... but how do I know what the error is that occurred?

Any suggestions?
Offline

support

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

Re: Error with POST request

PostWed Aug 08, 2018 10:35 am

Hi,

The recordcall property uses the filename callrecording by default. You will want to use that parameter name when referencing the audio file being sent. You will also want to ensure that the script that saves the audio file also returns valid VXML code. For example:

start.php
Code: Select all
<?php 
header("Content-type: text/xml");
echo "<?xml version=\"1.0\"?>\n";
?>

<vxml version="2.0">
  <form id="form1">
    <block>
      <prompt bargein="false">
        You will not hear this message in your recording.
      </prompt>
      <goto next="#form2"/>
    </block>
  </form>

  <form id="form2">
    <property name="recordcall" value="true"/>
    <block>
      <prompt>
        You will hear this message in your recording.
      </prompt>
      <submit next="save_recording.php" namelist="callrecording" method="post"/>
    </block>
  </form>
</vxml>
save_recording.php
Code: Select all
<?php 
header("Content-type: text/xml");
include('lib.php');

$result = saveCallRecording($_FILES['callrecording']);

echo "<?xml version=\"1.0\"?>\n";
?>
<vxml version="2.0">
<form>
  <block>
    <!-- <?= $result ?> -->
    <prompt> Recording saved. </prompt>
    <disconnect/>
  </block>
</form>
</vxml>

The start.php script will record the call during the form2 portion of the call and then send the audio file to be saved. The save_recording.php takes the POSTed audio file and will save it and then return valid VXML that ultimately ends the call. If you're expecting to save the audio file after the caller has ended the call, which can be accomplished via the catch tag, then you will not want to play an audio or TTS in the save script.

When an error occurs, it will be logged in the error logs. On the call, the caller will hear a TTS response stating what error occurred. It is possible to catch specific errors or events using the catch tag mentioned earlier. There is also the error tag which will catch all types of errors. This means that the caller will not hear any TTS error messages and can instead hear a cleaner technical difficulties message of your own wording.

Regards,
Plum Support
Offline

wes@@@

  • Posts: 6
  • Joined: Tue Aug 07, 2018 4:25 pm

Re: Error with POST request

PostWed Aug 08, 2018 1:24 pm

It's saved as "callrecording" even though it shows "call_recording" on the head as default in the fuse+ interface?

Here is how it currently looks, with everything else disconnected for testing purposes:
https://i.imgur.com/BknUyoY.png
The REST module currently has the timeout set to 30s as well.

More information:

The application I'm sending to is a node app hosted on GCloud that simply accepts the POST and sends a status code back (which is why I tried having the response from the app be empty first).

Upon checking the app's logs and the call log, I noticed that the app isn't even logging the POST and the call log shows:
Code: Select all
07 AUG 2018 04:22:40 PM -0500: var_68, [rest] - »
ERROR:
HTTP response code was non-2xx.
REQUEST:
URL: https://******.appspot.com/
TYPE: POST
User-Agent: curl/7.29.0
Variable Value
id 200060;006;1533676672
file <audio file upload>

(please note first portion of url has been removed for privacy)
Also, this error occurs even when I explicitly send a 200 status from my app. So, I'm unsure why this error is being shown.

Also, here is an example of log output when the app is POSTed to (this example is using postman):
Code: Select all
I  POST 200 187 B 3.9 s PostmanRuntime/7.1.5 / POST 200 187 B 3.9 s PostmanRuntime/7.1.5 5b6b491e00ff0651b1ed7152f30001737e67636c6f7564667573656c6f676765720001323031383038303874313432393530000100
  70.165.119.234 - - [08/Aug/2018:14:48:46 -0500] "POST / HTTP/1.1" 200 187 - "PostmanRuntime/7.1.5" "******.appspot.com" ms=NaN cpu_ms=5539 cpm_usd=2.0898e-8 loading_request=1 instance=00c61b117c95452111f67ec598645cb4d04e50cda881d95c794bfcdf45e528cddec5af4ae049 app_engine_release=1.9.54 trace_id=3fe5a6a4bb57b83f3d7fb3eff278179d
A  Server is running on port: 8080
A  POST to / received!
A  10000;10;1022
A  { fieldname: 'file',
A    originalname: 'wavy.wav',
A    encoding: '7bit',
A    mimetype: 'audio/wave',
A    buffer: <Buffer 52 49 46 46 2a 30 92 00 57 41 56 45 66 6d 74 20 12 00 00 00 01 00 02 00 44 ac 00 00 10 b1 02 00 04 00 10 00 00 00 64 61 74 61 04 30 92 00 00 00 00 00 ... >,
A    size: 9580594 }
A  Uploaded -> [object Object]

(again, url to app has been edited for privacy)

I assume an XML response is not required when using the rest data module. Is there not another way to remedy this?
Offline

support

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

Re: Error with POST request

PostThu Aug 09, 2018 11:18 am

Hi,

We see that you posted a similar question on the Fuse+ forum, we will consider this post closed and will provide all future responses there.

Regards,
Plum Support

Return to Plum DEV Q&A

Who is online

Users browsing this forum: No registered users and 1 guest

cron