URGENT problem with Podio API today
AnsweredWith the new Item ID changes today, we are seeing that Podio::getItem() is no longer working for us on NEW items... (still works fine on older items)... The stack trace and error are this:
[08/05/2013 10:45:32] main::getAppIDByItemURL::CACHEMISS for APP_ID
Fatal error: Uncaught PodioForbiddenError: "The user with id 648953 does not have the right view on item with id 380" Request URL: http://api.podio.com/item/380 Request Body: null Stack Trace: #0 /var/www/helpdesk/libs/PodioAPIV3/lib/Podio.php(268): Podio::request('GET', '/item/380', Array, Array) #1 /var/www/helpdesk/libs/PodioAPIV3/models/PodioItem.php(70): Podio::get('/item/380') #2 /var/www/helpdesk/libs/main.php(946): PodioItem::get('380') #3 /var/www/helpdesk/libs/main.php(1285): getItem('380') #4 /var/www/helpdesk/podio-item-reply/index.php(71): getAppIDByItemURL('https://podiohe...') #5 {main} thrown in /var/www/helpdesk/libs/PodioAPIV3/lib/Podio.php on line 238
[08/05/2013 10:45:32 CDT] ********************* EXCEPTION REPORT BEGIN ***************************************
[08/05/2013 10:45:33 CDT] Main::ExceptionHandler:Details:
Location: /var/www/helpdesk/libs/PodioAPIV3/lib/Podio.php:238
Error Description: GLOBAL(exception): Uncaught PodioForbiddenError: "The user with id 648953 does not have the right view on item with id 380"
Request URL: http://api.podio.com/item/380
Request Body: null
Stack Trace:
#0 /var/www/helpdesk/libs/PodioAPIV3/lib/Podio.php(268): Podio::request('GET', '/item/380', Array, Array)
#1 /var/www/helpdesk/libs/PodioAPIV3/models/PodioItem.php(70): Podio::get('/item/380')
#2 /var/www/helpdesk/libs/main.php(946): PodioItem::get('380')
#3 /var/www/helpdesk/libs/main.php(1285): getItem('380')
#4 /var/www/helpdesk/podio-item-reply/index.php(71): getAppIDByItemURL('https://podiohe...')
#5 {main} thrown
Time Stamp: Mon Aug 5 2013 10:45:32 CDT
The summary is that I am getting an exception when calling this line of code:
#2 /var/www/helpdesk/libs/main.php(946): PodioItem::get('380')
This same exact function works fine on all "OLD" items, but not those that have been newly created in Podio since today...
Please help! This affecting many users on our system, thanks
Patrick Steil
-
Hi Patrick,
I can infer that you are looking at an item URL to get the item_id. With the unique ID feature the item URLs changed to use the unique ID rather than the item_id. That's why the ID is only 3 digits now.
So you have two options:
- Stop looking at the URL to get the item_id and locate it some other way (I'm not sure why you need to look at the URL so it's hard to suggest changes)
- Use this API operation to get the item by the unique id (called app_item_id in API lingo). You'll need to supply an app_id as well since the unique IDs are only unique within an app so we need to know for which app you are getting items: https://developers.podio.com/doc/items/get-item-by-app-item-id-66506688
Makes sense?
/Andreas
-
In some cases we have to use the item_id from the URL since the user may access our tool via a Bookmarklet and we simply get the URL of the "item" which includes the item_id...
I never heard of "app_item_id"... is that new?
This was a big change, would have been good to get advance notice of this...
Patrick
-
It's new as of this morning: http://blog.podio.com/2013/08/05/uniqueid/
You can get the app by URL label: https://developers.podio.com/doc/applications/get-app-on-space-by-url-label-477105
All the best,
Andreas -
I just added app_item_id and app_id_id_formatted properties to the item model: https://github.com/podio/podio-php/commit/14dbd8649bf2f4910d58498ba64634cc2f2e4613
And, yes, you need to download the newest version of podio-php get get the newest code :)
/Andreas
PS. You're logged in as Tyra :)
-
All item views use the new app_item_id in the URL, no matter if the Unique ID is turned on for that app, so if someone is on an item view they are seeing the app_item_id in the URL. There are a few places that still use the item_id in the URL (e.g. the print item view). We'll change those over to use app_item_id over time.
-
Previously with the getitem(uniqueid) approach I could easily get the item and the app id... and I didn't need the spaceid...
Now, I am having to get the appid to get the itemid
But to get the appid by using PodioApp::get_for_url( $space_id, $url_label ), I also need the spaceid... so then I need to make another api call to get the spaceid...
Is there a better way to do this?
I REALLY need an API like:
$item = getItemFromAppItemURL( $url )
So just pass in the entire URL and it returns me the item...
Can we get this?
-
The Podio API and the podio web frontend are two separate entities and for that reason we try not to have them be dependent of each other. It's why we only have the bare minimum of "get by URL" operations in the API (the URLs in the frontend doesn't really have anything to do with the API).
Space URLs hardly ever change (And when they do it's something the user does manually) so you can cache those hard. App URL slugs can change when an app is modified so you can cache those hard and use a webhook to invalidate your cache whenever the app is modified. Overall there shouldn't be any noticeable performance impact for your users.
/Andreas
-
I do not agree... remember we are making the API calls from half way around the world... so at some point we have to make those api calls and they are not cheap... we do a lot of caching already... but this just adds to our app complexity...
And now with this change that I am trying to solve quickly I am having to write a bunch of new code I didn't need before because there is not an easy way to get back to the way it worked before... this would go very far in making the api much more developer friendly!
Pretty please, can we have an API call like:
$item = getItemFromAppItemURL( $url )
Is this very hard on your end to create?
-
And please keep in mind... we don't just have ONE workspace and App we are dealing with (that we would need to cache), we have hundreds and eventually thousands... so this is not the most scalable thing to have in place... it would be so much better to have these types of helper functions so we don't have to get the spaceid, appid just to get to the item... (when we already know the URL of the item)...
-
I am trying to follow your original suggestion:
- Use this API operation to get the item by the unique id (called app_item_id in API lingo). You'll need to supply an app_id as well since the unique IDs are only unique within an app so we need to know for which app you are getting items: https://developers.podio.com/doc/items/get-item-by-app-item-id-6650...
But in order to get the app_id, I have to call something like
PodioSpace::get_for_url( $appURL )
But I don't have the URL to the app at this point in my code, all I have is the url to the item... so should I get the spaceid so I can get the appid then?
-
I got this error when I called
PodioSpace::get_for_url( $attributes = array() );
{"error_parameters"=>{}, "error_detail"=>nil, "error_propagate"=>false, "request"=>{"url"=>"http://api.podio.com/app/space/264135/https:/infranetcom.podio.com/web-content-team/apps/cb-projects/items/5413", "query_string"=>"type=full", "body"=>nil, "method"=>"GET"}, "error_description"=>"No matching operation could be found. The path '/app/space/264135/https:/infranetcom.podio.com/web-content-team/apps/cb-projects/items/5413' was not found..", "error"=>"not_found"}
-
Here is a video showing you what happened as I mentioned in the last 2 comments...
-
Hi Tyra
This method expects to get the "URL label" also known as the "slug". In this case it would be "cb-projects". So the full request would be f.ex.
http://api.podio.com/app/space/264135/cb-projects
Alternatively you can also use this method:
https://developers.podio.com/doc/reference/resolve-url-66839423
by simply giving it the full URL for the item. Something like:
Notice that the parameter should be URL encoded (most likely done automatically).
This will give you back an object describing the type and id of the item, which you can then use to get the item.
Hope this helps,
Christian
-
What are the chances of getting an API call would be used like this:
$item = getItemFromAppItemURL( $url )
where $url is something like:
https://podiohelpdeskcom.podio.com/podiohelpdeskcom-app-data/apps/regression-tests/items/462
-
That is of course a possibility, but it does become a little much, as we would then need versions of many API methods, to get by URL. I think the second method I gave you does the job quite nicely, although it does require multiple API calls. Can you give it a try as it should be quite easy to use. I can try to get Andreas to add it to the PHP client.
-
Hey Patrick,
I think you have two good options for your use case:
- Since you are using a browser extension you can get the context data from the javascript layer. Try going to an item view in Podio and running the following in your javascript console: require('lib/Podio.UI').context(); That'll give you the current page context.
- Using the API operation Christian linked to might be more familiar to you. I've added the method in podio-php here: https://github.com/podio/podio-php/commit/e2b2a404b8f77518a6451961762f87e9e5f614bc
Since the operation returns all kinds of data you may not even have to subsequently use PodioItem::get() as you can create a new PodioItem object like so:
$reference = PodioReference::resolve(array('url' => 'https://podiohelpdeskcom.podio.com/podiohelpdeskcom-app-data/apps/regression-tests/items/462'));
$item = new PodioItem($reference->data);Makes sense?
/Andreas
-
Ok, I was able to add your new ::resolve function and that worked great and was super easy, thanks!
So next problem...
We use this code:
$results = PodioSearchResult::app( $config_app_id, $attributes );
to search through our "config" app for the item_id of a configured PodioTools app...
I verified that I can search that "config" app manually using the Podio UI, but in my code, it is returning zero results where this has been working fine for months...
Can you look into this, thanks!
Please sign in to leave a comment.
Comments
39 comments