API - Custom fields

Additional information

Updating custom field content

When you have custom fields setup for a project It is possible to update custom field content using the API. To do this you will need to know the type of field, the custom field ID and the value you want to update it to. Additionally if it is a select field type you will also need to know the valid options an their ID's. All of this information can be gained from the list custom field action which is documented below.

Example:

For this example we have two custom fields setup under project 1 for requirements, these are shown in the list action like:

{
  "requirement_custom_fields": [{
"id":40,
"field_name":"Critical",
"field_type": {
"number":2,
"type":"Select"
},
"position":1,
"select_options": {
10:"Yes",
11:"No"
},
"created_at":"2014-02-26T14:33:58Z",
    "updated_at":"2014-02-26T14:33:58Z"
},
{
    "id":1,
"field_name":"Further details",
"field_type": {
"number":1,
"type":"Text area"
},
"position":2,
"select_options": null,
"created_at":"2014-02-26T14:33:58Z",
     "updated_at":"2014-02-26T14:33:58Z"
}
  ]
}

 

To create a new requirement with these custom fields completed, you would create an api POST request that has the param's shown below.

Notes:

  • Under custom_fields the param's are made up by field_{custom_field_id})
  • If the custom field is a select, you will need to pass the id of the option that you would like setting and not the string value. (Shown in field_40)
HTTParty.post('https://api.testlodge.com/v1/account/1/projects/1/requirement_documents/1/requirements.json', body: { 
requirement: {
  title: 'Must authenticate',
   description: 'The body text',
custom_fields: {
field_1: 'Some further details that should be included',
field_40: 10
}
  }
})

 

List

Description: Provides a list of all custom fields for the given project

Endpoint: <base_url>/projects/{project_id}/custom_fields.json

Request: GET

Formats supported: JSON

Params:

  • project_id - {Integer} The associated project ID (Required)

Response

{
  "plan_content_custom_fields": [
    { .... },
    { .... }
  ],
"requirement_custom_fields": [
    { .... },
    { .... }
  ],
"step_custom_fields": [
    { .... },
    { .... }
  ],
"executed_step_custom_fields": [
    { .... },
    { .... }
  ]
}

Example ruby request

HTTParty.get('https://api.testlodge.com/v1/account/1/projects/1/custom_fields.json')

Example Response

Response code: 200

{
  "plan_content_custom_fields": [{
"id":1,
"field name":"Critical",
"field type": {
"number":2,
"type":"Select"
},
"position":1,
"select_options": {
1:"Yes",
2:"No"
},
"created_at":"2014-02-26T14:33:58Z",
    "updated_at":"2014-02-26T14:33:58Z"
},
    { .... }
  ],
"requirement_custom_fields": [{
"id":1,
"field name":"Acceptance criteria",
"field type": {
"number":1,
"type":"Text area"
},
"position":1,
"select_options": null,
"created_at":"2014-02-26T14:33:58Z",
    "updated_at":"2014-02-26T14:33:58Z"
},
    { .... }
  ],
"step_custom_fields": [{
"id":10,
"field name":"Browser",
"field type": {
"number":0,
"type":"Text field"
},
"position":1,
"select_options": null,
"created_at":"2014-02-26T14:33:58Z",
    "updated_at":"2014-02-26T14:33:58Z"
},
    { .... }
  ],
"executed_step_custom_fields": [
    { .... },
    { .... }
  ]
}

 

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Article is closed for comments.