Matt
Matt

Reputation: 2350

Creating item with podio api for PHP

I am trying to Create an item in the podio API for PHP. Here is my code:

Podio::setup($client_id, $client_secret);
Podio::authenticate_with_app($app_id, $app_token);
// Create a field collection with some fields.
// Be sure to use the external_ids of your specific fields
$fields = new PodioItemFieldCollection(array(
  new PodioTextItemField(array("external_id"=>"first", "values"=> "Han")),
  new PodioTextItemField(array("external_id"=>"last", "values"=> "Solo"))
));
// Create the item object with fields
// Be sure to add an app or podio-php won't know where to create the item
$item = new PodioItem(array(
  'app' => new PodioApp($app_id), // Attach to app with app_id=$app_id
  'fields' => $fields
));

// Save the new item
$item->save();

But I get error

Notice: Undefined index: request in C:\xampp\htdocs\PodioAPITesting\vendor\podio\podio-php\lib\PodioError.php on line 11

Fatal error: Uncaught PodioMissingRelationshipError: "Item is missing 
relationship to app" Request URL: Stack Trace: #0     C:\xampp\htdocs\PodioAPITesting\testPodioAPI.php(66): PodioItem->save() #1 {main} thrown in C:\xampp\htdocs\PodioAPITesting\vendor\podio\podio-php\models\PodioItem.php on line 75

Am I creating the item properly? Could it be because this app has more that two fields? ( I want to set 'first' and 'last', and leave the other fields blank for now)

Upvotes: 2

Views: 607

Answers (1)

Matt
Matt

Reputation: 2350

The problem was that my $app_id was a string when it should have been an integer.

Upvotes: 1

Related Questions