Search code examples
podio

Uncaught PodioBadRequestError: "Must specify either 'embed' or 'url'"


I need to set value for an embed field in Podio, and this is my code:

            $field_id='pdf-property-information';
            $options=$item->fields[$field_id]->values;
            if(empty($options)) 
                $item->fields[$field_id] =  new PodioEmbedItemField($field_id);

            // Create embed
            $embed = PodioEmbed::create(array('url' => $pdf_property_information));

            // Set using object
            $item->fields[$field_id]->values = $embed;

            // Set using associative array
            $item->fields[$field_id]->values = array('embed_id' => $embed->embed_id);

And this is the error I get:

Fatal error: Uncaught PodioBadRequestError: "Must specify either 'embed' or 'url'" Request URL: http://api.podio.com/item/826141668 Stack Trace: #0 /home/apibind/public_html/mail_chimp/podio-php-4.3.0/lib/Podio.php(355): Podio::request('PUT', '/item/826141668', Array) #1 /home/apibind/public_html/mail_chimp/podio-php-4.3.0/models/PodioItem.php(183): Podio::put('/item/826141668', Array) #2 /home/apibind/public_html/mail_chimp/podio-php-4.3.0/models/PodioItem.php(66): PodioItem::update(826141668, Array, Array) #3 /home/apibind/public_html/sourcingplatform/trunk/add.php(403): PodioItem->save() #4 {main} thrown in /podio-php-4.3.0/lib/Podio.php on line 289


Solution

  • You have to pass the embed_id with array key "embed". Here your final line will be like,

     // Set using associative array
     $item->fields[$field_id]->values = array('embed' => $embed->embed_id);