Getting data into Twilio parsed variable

It took several attempts, but I eventually found out why I could not access the value of a "parsed" variable within Twilio Studio while using the HTTP Widget. Someone else may encounter this error, so here's how I resolved it. The following 3 attempts are screenshots from the log viewer built in to the studio.

1. This one is incorrect because it sends content_type "text/html." Notice there isn't even a "parsed" variable, as seen in the next screenshot. This is because Twilio only parses variables from Content Type "application/json".

2. This one is incorrect because the JSON string is quoted. We correctly sent "application/json" but quoted the JSON. In other words, do not send "{JSON}" but rather, send {JSON}.

3. This one is finally correct. We get a parsed variable.

Here is the PHP code which correctly generated the variable:

 

<?php

$data = array(\"caller-exists\"=>1);

header(\'Content-Type: application/json\');

echo json_encode($data);

?>

Add a comment

HTML code is displayed as text and web addresses are automatically converted.

Page top