Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New item is not created #213

Closed
wasimakaram opened this issue Oct 2, 2021 · 2 comments
Closed

New item is not created #213

wasimakaram opened this issue Oct 2, 2021 · 2 comments
Assignees

Comments

@wasimakaram
Copy link

Hi
I want to create a new item but it failed
My Code is given below

<?php
require __DIR__ . '/vendor/autoload.php';
require_once("invoice_app_credentails.php");
Podio::setup(CLIENT_ID, CLIENT_SECRET);
Podio::authenticate_with_app(APP_ID, APP_TOKEN);
$fields = new PodioItemFieldCollection(array(
  new PodioTextItemField(array("external_id" => "title", "values" => "Wasim Akram")),
  new PodioTextItemField(array("external_id" => "email-address", "values" => "info@wasimamjad.com")),
  new PodioTextItemField(array("external_id" => "invoice-number", "values" => "123456")),
));
$item = new PodioItem(array(
  'app' => new PodioApp(APP_ID), // Attach to app with 
  'fields' => $fields
));
$response = $item->save();
echo "<pre>";print_r($response);die;

It gives me the following error
Fatal error: Uncaught PodioMissingRelationshipError: "Item is missing relationship to app" Request URL: Stack Trace: #0 /home/customer/www/measuredsurveyexperts.com/public_html/Podio_Xero_integration/create_podio_invoice.php(24): PodioItem->save() #1 {main} thrown in /home/customer/www/measuredsurveyexperts.com/public_html/Podio_Xero_integration/models/PodioItem.php on line 78

Actually when I want to create an object of PodioApp class with APP_ID and assign that object to PodioItem class. The APP_ID is assigned properly.

When I put APP_ID hardcoded in the file models->PodioItem.php on line number 71, then it's working fine. My hardcoded id is given below

if ($this->id) {
return self::update($this->id, $json_attributes, $options);
} else {
$this->app->id = 26545976;
if ($this->app && $this->app->id) {
$new = self::create($this->app->id, $json_attributes, $options);
$this->item_id = $new->item_id;
return $this;
}

I think there is an issue in the library. Can you please help me?
Thanks

@daniel-sc
Copy link
Member

Hi @wasimakaram ,

On first glance, it looks like you found a bug.

Could you tell which version of PHP and of this library you are using?

Best, Daniel

@daniel-sc daniel-sc self-assigned this Oct 4, 2021
@daniel-sc
Copy link
Member

Hi @wasimakaram

I could reproduce this and found the solution: You need to make sure APP_ID is a number (and not a string).
E.g. define('APP_ID', 123456789);

Let me know if this does not work!

Best, Daniel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants