Kamafeather
Kamafeather

Reputation: 9835

Get subset of fields, from filtered items on Podio API

I want to filter items from a Podio app, and fetch just the values for a subset of specific fields.
This should hopefully reduce the response time of the API.

The number of fields returned can be limited by specifying the fields query GET parameter.
But it doesn't seem to work as expected and the documentation doesn't go in detail.


Fetch subset of fields for filtered-items?

with /item/app/{app_id}/filter/micro?fields=items.fields(email) but the field isn't returned.
What am I doing wrong? I'd expect to get the micro view and add the email field to it.

Fetch a standard view instead of listing all fields

with /item/app/{app_id}/filter/?items.view(mini) but doesn't seem to work with any custom defined view.

The documentation is unclear on what parameters can be used on which endpoints.

How to get a subset of the fields from an app view:

  1. provide the name of a custom view? In my experience all the fields are still returned.

  2. provide the name of a standard view, micro, mini, full, via fields=items.view(micro); the standard are not ideal for my use case. Is it possible to filter using a custom view?

  3. provide the name of a standard view (micro/mini) and specify additional fields via GET parameter fields=items.fields(email,name,city)?
    (I wasn't able to make this work either)

My preferred way would be the first one, so I can programmatically choose fields without having to configure them in Podio.

The documentation is not really clear on what's possible (and might be not up to date), on what params to use and on what format should be provided. Also isn't clear what can be used with item/app/APPID/filter, item/ITEMID. Also info found on the Podio forum are discordant.

How to return a subset of fields, when filtering on an App?

(the purpose is to slim down the API request, reduce the workload and get a faster response time)


EDIT:

NOTE: that the Podio concept of App's FIELDS is not the same as the RESTful concept of FIELDS.
Hence using the GET fields parameter in the way that Deepa Podio explained, works on the RESTful response fields, not on the Podio fields!
So...

How to return a subset of Podio Fields, when filtering on a Podio App?

Example, if the filter API response is:

[
    {
      "sharefile_vault_url": null,
      "title": "Test item",
      "app_item_id": 2552,
      "fields": [
        {
            "type": "text",
            "field_id": 217293226,
            "label": "Birth Date",
            "config": {
              "label": "Birth Date",
              "settings": {
                "format": "plain",
                "size": "small"
              }
            },
            "external_id": "birth-date"
        {
          "type": "app",
          "field_id": 219992505,
          "label": "Number of Parents",
          "values": [
            {
              "value": ...
            }
          ],
          "external_id": "number-of-parents"
        }
    }
]

How to return just the number-of-parents Podio field and exclude all the others?

Upvotes: 0

Views: 570

Answers (1)

Deepa Podio
Deepa Podio

Reputation: 11

By default, the API provides a detailed response of the app or the view provided by the user. If we need to get subset of the details, we need to use items.view(micro/mini/full) based on the requirements. In case, the results provided by items.view(micro/mini/full) does not have the field the user requires we can use the items.view(micro).fields(<desired_field>) to get the desired fields added to the response.

Standard View:

  1. To get the complete default (standard) view details of an app we need to use - POST /item/app/{app_id}/filter/
  2. To get the subset of the standard view, we need to provide field parameters as you have specified. But the usage is as follows - POST /item/app/{app_id}/filter?fields=items.view(micro).fields(files). The files field used here is just an example.

Custom View:

  1. To get the filter to work on any Custom designed view we need to make use of the API - POST /item/app/{app_id}/filter/{view_id}/
  2. To get subset of the details of the Custom view, its similar to previous one but with view_id in the API - POST /item/app/{app_id}/filter/{view_id}?fields=items.view(micro).fields(files,created_on). Here you can replace files, created_on to the fields you hope to filter from your app. This is an example to show we can use a single field or multiple fields which are “,” separated.

It works for Standard and Custom views, just that when using Custom views you need to make use of the other API where you need to provide the view_id. It works for Team-views and Private-views.

Upvotes: 1

Related Questions