Build Your Own Using JSON with the FogBugz API


Follow
 

If you’re using FogBugz On Demand, you can send JSON requests to the FogBugz API and receive JSON responses in return. For complete documentation on supported commands and arguments, please see our XML API documentation.

There are a few key differences to consider when building your JSON requests:

  • The API URL will be: https://yoursite.fogbugz.com/f/api/0/jsonapi
  • Only POST requests are supported
  • The POST must contain no parameters, and be passed a JSON object in the raw body
  • Strings containing lists (e.g. cols=sTitle,sStatus) must be sent as an array (e.g. "cols": ["sTitle", "sStatus"])
  • The JSON API understands values other than strings where appropriate:
    • Fields that begin with ix (e.g. ixBug) will accept and return integer values
    • Fields that being with f (e.g. fAdministrator) will accept and return boolean values (true/false)

Examples

Logging On

Request Body:

{
  "cmd": "logon",
  "email": "email@example.com",
  "password": "yourpassword"
}

Response:

{
  "data": {
    "token": "24dsg34lok43un23"
  }
  ...
}

Searching Cases

Request Body:

{
  "cmd": "search",
  "token": "24dsg34lok43un23",
  "q": "test",
  "max": 2,
  "cols": ["sTitle", "sStatus"]
}

Response:

{
  "data": {
    "count": 2,
    "totalHits": 11,
    "cases": [
    {
      "ixBug": 29,
      "operations": [
        "edit",
        "assign",
        "resolve",
        "email"
      ],
      "sTitle": "test 123",
      "sStatus": "Active"
    },
    {
      "ixBug": 22,
      "operations": [
        "edit",
        "assign",
        "resolve",
        "email"
      ],
      "sTitle": "test 456",
      "sStatus": "Active"
    }
  }
  ...
}

Error Handling

Errors will be returned in the errors array:

{
  ...
  "errors": [
    {
      "message": "Error 3: Not logged in",
      "detail": null,
      "code": "3"
    }
  ]
  ...
}

See our XML API documentation for a full list of error codes.