"Item is missing relationship to app" when calling item->save()
AnsweredFinally got all my API v2 code converted to V3... and now trying to do do this item creation below but getting this error:
Item is missing relationship to app
$item = new PodioItem(array(
'app' => new PodioApp( $OrganizationsAppID ),
'fields' => array(),
'external_id' => NULL
));
$item->fields = array(
new PodioTextItemField('organizationid2'),
new PodioTextItemField('organization-name'),
new PodioTextItemField('account-type'),
new PodioTextItemField('account-status')
);
// Give the fields values:
$item->field('organizationid2')->set_value($this->org_id);
$item->field('organization-name')->set_value('something');
$item->field('account-type')->set_value($accountTypeValue);
$item->field('account-status')->set_value($accountStatusValue);
printInfo( "Saving the Organization item..." );
// Finally save the item to Podio:
try {
$this->organization_item_id = $item->save();
} catch (PodioError $e) {
printInfo( "PTOrganization:: ERROR creating organization item id " );
echo dump($e->body);
exit;
}
I got this code from the example code that came with the API V3 library... can't seem to figure out what is wrong... thanks!
Patrick
-
Are you 100% sure $OrganizationsAppID is an integer? If it's a string your code will fail.
The error is because the PodioApp instance is not being created (so the item doesn't know to which app it belongs). You can inspect $item->app to see what you really have store in there.
/Andreas
Please sign in to leave a comment.
Comments
2 comments