Access Custom Fields and Other Plugin Data with the JSON API


Follow

Overview

You can get and set plugin values (Custom Fields plugin or another such as Project Backlog or Kanban) on cases if you know their super-secret (long) name. You can get values if you only know part of the name, which will also then tell you the long name.

Example:

You have a custom field called “adada“ and issue an API request:

POST https://kakapo.fogbugz.com/api/viewCase

{
	"ixBug": 144,
	"cols": ["sTitle", "sCategory", "adada"],
	"token": "y0urs3cret4p1t0k3n"
}


This returns some JSON:

{
    "data": {
        "count": 1,
        "totalHits": 1,
        "cases": [
            {
                "ixBug": 144,
                "operations": [
                    "edit",
                    "assign",
                    "resolve",
                    "email"
                ],
                "sTitle": "Godkänna CleanCash",
                "sCategory": "Inquiry",
                "adada": 123123,
                "plugin_customfields_at_fogcreek_com_adadai67": 123123
            }
        ]
    },

    […redacted for space…]
}


It includes the name of the key you specified and its long name. Note that there may be duplicates of the short name, so it is better to use the long name. Setting a value requires using the long name (as it is too dangerous to guess):

POST https://kakapo.fogbugz.com/api/edit

{
	"ixBug": 144,
	"sTitle": "hello",
	"plugin_customfields_at_fogcreek_com_adadai67": 45,
	"token": "y0urs3cret4p1t0k3n"
}


Important

  • If you want to get all the custom fields you have setup, use "cols": "plugin_customfields".
  • When querying a custom field via the JSON API, you’ll need to substitute an ‘x’ for each space or special character (such as ‘?’) in the custom field name. For example, “My Field 1” should be “MyxFieldx1” when used with cols.
  • The name of the custom field used with cols always matches the first name of the custom field. If you change the name of the custom field, although all areas of FogBugz will display the new name, the JSON API will still expect the original name when used with cols.

Known Issues

  • Note that you cannot clear Date or Date and Time type field via the JSON API.
  • Additionally, there is a known issue when setting a Date and Time type field via the JSON API, where the time will be set 10 hours earlier than the datetime string that is passed in.