Post

1 follower Follow
0
Avatar

Search for space contact with email?

Hi! I'm trying to find a space contact with a specific email address (to avoid duplicates) but I get an error saying I have an invalid field filter.

How am I supposed to use the {field}-field?

Thanks!

// Carl-Fredrik

Elvenite AB - Podio Partner 

Carl-Fredrik Herö Answered

Please sign in to leave a comment.

22 comments

0
Avatar

You can't test out the filters in the API sandbox because the key is dynamic. You can only do it in your actual code. You need to use 'mail' I believe for the key and then the email address as the value.

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

Ok, so the parameters in my screenshot it correct?

Carl-Fredrik Herö 0 votes
Comment actions Permalink
0
Avatar

No, that sandbox form is broken. We should in fact hide the {field} parameter as it doesn't work, but the whole thing is autogenerated from (of course) data in Podio, so we haven't gotten around to that.

You request would have to include &mail=bhll_8766@veryrealemail.com to be correct, but as Andreas pointed out, you can't make that request from the sandbox form, you have to do it from you own code to test it out.

Casper Fabricius 0 votes
Comment actions Permalink
0
Avatar

Casper, et. al... can someone post the code necessary to do a search based on email address to determine if a space contact already exists?

That would be greatly appreciated!  :)

Thanks!

Patrick Steil 0 votes
Comment actions Permalink
0
Avatar

What type of Auth does this require?  If user, that won't work for me as I need to use Auth... my current code is actually using PodioItem::filter to retrieve every Item and then is able to loop over the returned items to get to the contacts... so I have access using App Auth... what I need is a much more efficient way to get to this data as the method I am using has finally caused us to start timing out... 

 

Can that api be opened up for use by App Auth?

Patrick Steil 0 votes
Comment actions Permalink
0
Avatar

App auth provides access to a single app. Space contacts has access to all contacts on that space, without regard for which apps they are used in. So it cannot be used with app auth.

If you get the correct data when fetching items you can continue to do that? I don't know what you mean by timing out, so I can't suggest any direction there. Most likely it'll make sense for you to process fewer items at the time?

/Andreas

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

When there are hundreds of contacts in the workspace, then it takes a long time - 10-20 seconds or more to retrieve all the items in order to loop over them in my PHP code... this is a big drain on Podio and my app... and now it is causing problems on our server... 

What we really need is an api specifically that can just tell me if the email address exists as a space contact... since I can get to that info by looping over every item in the App, it would make sense that maybe you all could consider opening this up somehow via the API... 

This is a huge need!  :)  

Thanks!

Patrick Steil 0 votes
Comment actions Permalink
0
Avatar

I'll add the "Get contacts in app" as a feature request on our end. I'm not sure if it's actually feasible or not.

All this is something you can cache on your end though. You should not have to loop over all existing items more than once. After that you can setup a webhook for all contact fields so you can be told when a contact reference changes (and for when items are created, of course). Create a local cache of the data you need to check and only fetch items again when they have actually changed.

/Andreas

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

Ok, I can go down that road, but it sure would be a heck of lot easier to just make one quick api call... 

 

 

Patrick Steil 0 votes
Comment actions Permalink
0
Avatar

I agree. If you don't want to bother with webhooks you can also just store a timestamp for the last time you checked the app and then use PodioItem::filter() with a sort order on last edited date and only fetch items until you reach the time you last checked. Then you will not be searching through the entire app each time. Again with a local cache.

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

Can I call PodioItem::filter and only retrieve items since that date/time?  What would that look like?

Patrick Steil 0 votes
Comment actions Permalink
0
Avatar

Please also consider offering a "Get contacts in app" API call... this would be so much lighter for both sides... I feel like I am having to pull way too much data from Podio to do this and I have to do this on EVERY time we process a new email into Podio... thanks... 

Patrick Steil 0 votes
Comment actions Permalink
0
Avatar

You can't filter on last_edit_on, but you can sort on it. So you'd sort by that and go through items until you reach a last_edit date that's prior to your last data gathering. That way you're sure to have the most recent information since a particular time. Again, you should cache locally so you're not going through all items all the time.

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

Andreas, I still feel like there should be an API for this... I don't want to have the expense of doing this nor do I want to make Podio work this hard to return all this data... :)

And consider this:

  1.  If I was a user of an App then I would have access to the space contacts (granted I guess I would have access to the whole space, but how do you handle this for a user who access to one sole item?  Wouldn't they be able to access space contacts to setup a new contact on an item?

  2.  Since I can already get to this data by looping over all items, it is not introducing any new security risk to allow this api call... 

Thanks for your consideration...  

Patrick Steil 0 votes
Comment actions Permalink
0
Avatar

Alright, pull the newest version of podio-php and give PodioContact::get_for_app($app_id, array('mail' => 'sample@example.com')); a try

Andreas Haugstrup Pedersen 0 votes
Comment actions Permalink
0
Avatar

Woo hoo Andreas, thanks!!!!!  (Sorry, didn't see the email on this until today... )

Patrick Steil 0 votes
Comment actions Permalink