Post

3 followers Follow
0
Avatar

URGENT problem with Podio API today

With 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

http://www.podiotools.com

 

Tyra Steil Answered

Please sign in to leave a comment.

39 comments

0
Avatar

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:

  1. 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)
  2. 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

Andreas Haugstrup Pedersen 0 votes
0
Avatar

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

 

Tyra Steil 0 votes
0
Avatar

So is there a new commit to the API we need to download also?

How can I get the unique ID (app_item_id) from the "item_id"?  I need an API call for that also... 

Tyra Steil 0 votes
0
Avatar

I am logged in as Tyra because the Forums code logs me out every time I post!  :)

Thanks for adding this... this should have been announced to API developers and Podio Preferred Partners... 

Tyra Steil 0 votes
0
Avatar

Since items created before today still have the "unique id" in the url string, how can I tell the difference between these and the new ones besides looking at the value / size of the id?

Tyra Steil 0 votes
0
Avatar

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.

Andreas Haugstrup Pedersen 0 votes
0
Avatar

Ah, its actually my old links that we recorded in the comments that have the old unique id... thanks... 

Tyra Steil 0 votes
0
Avatar

How can I get the uniqueID for the item from the app_item_id?  I desperately need that or I am going to have to rewrite a lot of code and my system is basically down until I can do all that... 

Tyra Steil 0 votes
0
Avatar

Oh I guess I can get that from PodioItem::get_by_app_item_id... never mind... 

Tyra Steil 0 votes
0
Avatar

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?

Tyra Steil 0 votes
0
Avatar

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

Andreas Haugstrup Pedersen 0 votes
0
Avatar

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?

 

Tyra Steil 0 votes
0
Avatar

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)... 

Tyra Steil 0 votes
0
Avatar

I am trying to follow your original suggestion:

  1. 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?

 

Tyra Steil 0 votes
0
Avatar

I was able to use the api reference to test getting the space by using the item's url... that worked...

But when I tried to get the app by URL using the item's url that did not work... 

Tyra Steil 0 votes
0
Avatar

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"}

Tyra Steil 0 votes
0
Avatar

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:

https://api.podio.com/reference/resolve?url=https:/infranetcom.podio.com/web-content-team/apps/cb-projects/items/5413

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 

Christian Holm 0 votes
0
Avatar

Christian, thanks... "Tyra" is me - Patrick... my ID won't work on the forums today... logs me out every time I try to do something... 

I'll try that... not sure why this "slug" thing isn't better documented... 

 

Tyra Steil 0 votes
0
Avatar

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.

Christian Holm 0 votes
0
Avatar

Or at this point, just having the 

PodioApp::get_for_url

call be able to handle the new URLs to the app items just like the space:get_for_url supports would be great too... 

and a lot easier for you probably... 

 

Tyra Steil 0 votes
0
Avatar

Hey Patrick,

I think you have two good options for your use case:

  1. 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.
  2. 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

Andreas Haugstrup Pedersen 0 votes
0
Avatar

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!

Tyra Steil 0 votes