.NET FilterItems
AnsweredHi again -
I'm making progress with my science project and have run up against the wall. I'm attepting to fetch items in my app based on a Category field where the value is set to 'Open'. I know I'm doing something wrong in the filter - it appears that it's honoring the field id since if I pass 'null' as the second member in the pair I successfully retrieve items with no value in that field. However if I pass the the value I'm looking for is get an error. I have also tried passing the optionId (1 or 2) with the same result.
Dictionary<string, string> filter = new Dictionary<string, string>();
filter.Add("23157745", "Open"); // Invalid value u'Open': Must not be basestring (at values)
//filter.Add("23157745", null); // works
var client = Podio.API.Client.ConnectAsApp(podioClientId, podioClientSecret, podioAppId.ToString(), podioAppToken, uri);
int limit = 100; // Max allowed is 500 items per request;
int offset = 0;
var items = client.ItemService.FilterItems(podioAppId, limit, offset, filter);
Thoughts?
-
I only mentioned optionId in the context of providing a '1' or '2' as the value in the filter as opposed to the text values 'Open' or 'Closed'. I have already figured out how to update the Category field. I'm just trying to find out if there's something I'm missing in creating the filter.
-
Hmmm ... looking at the FilterItems method, it looks like it's taking a Dictionary object of <string,string> as the filter parameter. Am I reading this wrong?
public PodioCollection<Item> FilterItems(int appId, int limit, int offset, Dictionary<string, string> filters = null, bool? remembered = null, string sortBy = null, bool? sortDesc = null)
So filter.Add("123123123", "1") should work, no?
-
_response.PodioError.error_description: Invalid value u'1': Must not be basestring (at values)
(new System.Collections.Generic.Mscorlib_DictionaryDebugView<string,string>(_response.RequestData)).Items[0].Key: json
(new System.Collections.Generic.Mscorlib_DictionaryDebugView<string,string>(_response.RequestData)).Items[0].Value: {"filters":{"20912595":"1"},"sort_by":null,"sort_desc":null,"limit":100,"offset":0,"remember":null}
-
Thanks. I tried you suggestion but no luck. Since the FilterItems method accepts a Dictionary <string , string> object for the filter the code won't even compile.
1>V:\VS tools\Contour\Sample\ContourUtil\util.cs(186,25,186,90): error CS1502: The best overloaded method match for 'Podio.API.Services.ItemService.FilterItems(int, int, int, System.Collections.Generic.Dictionary<string,string>, bool?, string, bool?)' has some invalid arguments
1>V:\VS tools\Contour\Sample\ContourUtil\util.cs(186,83,186,89): error CS1503: Argument 4: cannot convert from 'System.Collections.Generic.Dictionary<string,int>' to 'System.Collections.Generic.Dictionary<string,string>' -
Indeed this is the issue! Attaching modified ItemService.cs - changed the request variable to IDictionary<string, object>. Modified the code to pass same - works great now.
var client = Client.ConnectAsApp(podioClientId, podioClientSecret, podioAppId.ToString(), podioAppToken, uri);
int limit = 100; // Max allowed is 500 items per request;
int offset = 0;
int status_new = 1; // Status = New
int status_submitted = 2; // Status = Submitted
string fld_status = "23326810";
Dictionary<string, object> filter = new Dictionary<string, object>();
int[] parm = new int[1];
parm[0] = status_submitted;
filter.Add(fld_status, parm);
var items = client.ItemService.FilterItems(podioAppId, limit, offset, filter);Much appreciated! Hope this helps.
-
Hi Steve,
The Filter Items method only makes it possible to filter for empty values on the following field types: Contact, App Reference, Category and Question. It's not possible to search or filter for empty values in any other field type.
For more advanced search you can take a look at our search interface at: https://developers.podio.com/doc/search -- it will get you some of the way.
/Andreas
Please sign in to leave a comment.
Comments
17 comments