GetFields

From ARK
Revision as of 12:41, 24 March 2016 by John Layt (talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This method is used to get the values of a field or fields attached to an item. It will return a JSON array of all the values.

Please note this method respects any security conditions set in the subform configuration - therefore if fields are, for instance, being restricted on userids or security groups they will not be made available for return by the API.

Path

http://your.ark.instance/api.php?req=getFields

Arguments

Mandatory

  • itemkey - this is the itemkey of the required module (for instance 'cxt_cd').
  • item_value - this is the ARK item that you are interested in. This should be sent in the form item_key=item_value. As an example: cxt_cd=LK12_1. A list of available items can be supplied by describeItems.
  • fields[] - this is the name of the field that you want to return. If more than one field is required an array can be sent using fields[] = my_great_field. The field names available can be retrieved using describeFields()

Optional

  • aliased - set this argument to 'true' if you want the human-readable aliases to be returned

If anonymous logins are not enabled a username and password will need to be supplied:

  • handle - username
  • passwd - password

The method returns a JSON array unless otherwise specified:

  • format - 'json' by default, but sending 'html' prints a human-readable array to screen

Example

Example 1 - Retrieve a single field attached to an item with aliases

http://your.ark.instance/api.php?req=getFields&fields=conf_field_description&itemkey=hut_cd&hut_cd=LK12_1&handle=johndoe&passwd=johndoepassword

Example return (returned JSONified - displayed as an array here for ease of viewing):

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [id] => 1
                    [current] => House 1
                    [txt] => House 1
                )

            [aliases] => Array
                (
                    [en] => Notes
                )

        )
)

Example 2 - Retrieve multiple fields attached to an item

http://your.ark.instance/api.php?req=getFields&itemkey=hut_cd&hut_cd=LK12_1&fields[]=conf_field_description&fields[]=conf_field_direction&fields[]=conf_field_diameterhandle=johndoe&passwd=johndoepassword

Example return (returned JSONified - displayed as an array here for ease of viewing):

Array
(
    [0] => Array
        (
            [0] => Array
                (
                    [id] => 1
                    [current] => House 1
                    [txt] => House 1
                )

            [aliases] => Array
                (
                    [en] => Notes
                )

        )

    [1] => Array
        (
            [0] => Array
                (
                    [id] => 39
                    [current] => 89
                    [attribute] => 89
                    [boolean] => 1
                )

            [aliases] => Array
                (
                    [en] => Door Direction
                )

        )

    [2] => Array
        (
            [0] => Array
                (
                    [id] => 14
                    [current] => 12
                )

            [aliases] => Array
                (
                    [en] => Diameter
                )

        )

)