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

Invalid Item #139

Closed
denerFernandes opened this issue Jun 21, 2017 · 3 comments
Closed

Invalid Item #139

denerFernandes opened this issue Jun 21, 2017 · 3 comments

Comments

@denerFernandes
Copy link

denerFernandes commented Jun 21, 2017

Hi, i create item with Api, but i receive this error:

Fatal error: Uncaught PodioBadRequestError: "O item referenciado não é válido" Request URL: http://api.podio.com/item/app/18730870/ Stack Trace: #0 /var/www/html/guro/vendor/podio/podio-php/lib/Podio.php(352): Podio::request('POST', '/item/app/18730...', Array, Array) #1 /var/www/html/guro/vendor/podio/podio-php/models/PodioItem.php(167): Podio::post('/item/app/18730...', Array) #2 /var/www/html/guro/vendor/podio/podio-php/models/PodioItem.php(71): PodioItem::create(18730870, Array, Array) #3 /var/www/html/guro/index.php(41): PodioItem->save() #4 {main} thrown in /var/www/html/guro/vendor/podio/podio-php/lib/Podio.php on line 289

Thank's for help!

@denerFernandes denerFernandes changed the title Created Item in Blank Invalid Item Jun 21, 2017
@cmchase
Copy link
Contributor

cmchase commented Jun 21, 2017

Is that backslash in the PodioApp constructor a typo here or is that in your code? Have you set $app_id to a valid ID elsewhere in your code?

@denerFernandes
Copy link
Author

denerFernandes commented Jun 21, 2017

I resolve my first erro, but i receveive this erro now:

Fatal error: Uncaught PodioBadRequestError: "O item referenciado não é válido" Request URL: http://api.podio.com/item/app/18730870/ Stack Trace: #0 /var/www/html/guro/vendor/podio/podio-php/lib/Podio.php(352): Podio::request('POST', '/item/app/18730...', Array, Array) #1 /var/www/html/guro/vendor/podio/podio-php/models/PodioItem.php(167): Podio::post('/item/app/18730...', Array) #2 /var/www/html/guro/vendor/podio/podio-php/models/PodioItem.php(71): PodioItem::create(18730870, Array, Array) #3 /var/www/html/guro/index.php(41): PodioItem->save() #4 {main} thrown in /var/www/html/guro/vendor/podio/podio-php/lib/Podio.php on line 289

My code:

$client_id = '-----';
$client_secret = '-----';
$app_id = '------';
$app_key = '------';

Podio::setup($client_id, $client_secret);
Podio::authenticate_with_app($app_id, $app_key);

Podio::set_debug(true);

$fields = new PodioItemFieldCollection(array(
new PodioItemField(['external_id' => 'resource', 'values' => 17]),
new PodioDateItemField(['external_id' => 'booking-date', 'values' => ["start" => "2018-12-31 11:27:10", "end" => "2019-01-31 11:28:20"]]),
new PodioItemField(["external_id" => "client-or-projects", "values" => 321]),
new PodioItemField(["external_id" => "details", "values" => "asasas"]),
new PodioTextItemField(["external_id" => "hours-per-day", "values" => 8]),
));

//Make new Item
$item = new PodioItem(array(
'app' => new PodioApp(intval($app_id)),
'fields' => $fields
));

//Save Item
$item->save();

@cmchase
Copy link
Contributor

cmchase commented Jun 21, 2017

That error is getting thrown because the referenced item isn't valid. Could there have been changes to the app that could have later invalidated your code? Can you confirm that the fields are correct by using get?

https://developers.podio.com/doc/items

Just so you know, we have a tag on StackOverflow for podio where other developers can chime in with their suggestions. If you continue to have trouble it would be a good idea to reach out there and add podio as a tag:

https://stackoverflow.com/questions/tagged/podio?sort=newest

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

3 participants