.NET FilterItems

Answered

Comments

17 comments

  • Andreas Haugstrup Pedersen

    Hi Rich,

    I believe you should be passing the option id as an array instead of a single value.

    /Andreas

    0
    Comment actions Permalink
  • Rich Stoldt

    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.

    0
    Comment actions Permalink
  • Casper Fabricius

    You should pass in an array of option ids to filter by. Something like this (untested):

    filter.Add("23157745", [1]);

    0
    Comment actions Permalink
  • Rich Stoldt

    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?

    0
    Comment actions Permalink
  • Rich Stoldt

    Anyone.  Thanks in advance.

    0
    Comment actions Permalink
  • Rich Stoldt

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

    0
    Comment actions Permalink
  • Casper Fabricius

    "Must not be basestring" means that "1" should not be passed as a string. Try it as an plain int, simply 1, or as an array as I suggested [1].

    0
    Comment actions Permalink
  • Rich Stoldt

    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>'

    0
    Comment actions Permalink
  • Casper Fabricius

    Probably a bug in the .NET client then. Should probably have been Dictionary<string, object>. The .NET client is user contributed, and we don't currently have any resources to bugfix and expand the client. We will happily accept pull requests.

    0
    Comment actions Permalink
  • Rich Stoldt

    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.

    0
    Comment actions Permalink
  • Aurélien PETIT

    Hi Rich, Casper,

    This modification seems to be exactly what I need to filter my request.

    But as I use SharpDevelop and not Visual Studio, i can't import casper's sources from GitHub.

    Can you publish an updated .dll with this new ItemService.cs ?

    Many thanks.

    0
    Comment actions Permalink
  • Rich Stoldt

    You should be able to just download the source from GitHub as a ZIP or TARBALL.  I don't know if they've incorporated my changes into their baseline so you'll need to look.  You may need do diff their ItemService.cs with my version.

    0
    Comment actions Permalink
  • Kasper Andersen

    Can I get you to do a pull-request on GitHub with the bugfix, then I'll happily merge it into the codebase.

    0
    Comment actions Permalink
  • Rich Stoldt

    Done.  Sorry but it took me this long - I had to figure out the whole GitHub thing.  At least I avoided posting another n00b question :)

    0
    Comment actions Permalink
  • Kasper Andersen

    Thank you for your contibution! - I have made a comment regarding your pull-request on GitHub, could I ask you to revise it?

    0
    Comment actions Permalink
  • Steve Dieckbrader

    How may I create a filter that returns items where a simple text field is empty? The API errors with all attempts at guessing so far: 1) null, 2) "", 3) String.Empty

    And while we're at it, how might I filter using OR, NOT, RegEx, substring, etc.?

    0
    Comment actions Permalink
  • Andreas Haugstrup Pedersen

    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

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk