HTTP Verb: POST

Available statuses: 201 Created, 404 Not Found, 422 Unprocessable Entity

Object: CustomField

Location: available

Formats: XML, JSON

Create a custom field and return the body of newly created object in requested format among with its location in a Location: \_location header.

Params

To create a custom field, a data body must be provided. Data can be provided in three formats: XML, JSON and query string. To specify data type of XML or JSON add the Content-type: application/(json|xml) header to request headers, if you want to provide query string simply skip the Content-type header.

All params should be sent in the custom_field namespace, e.g.:

XML

<custom-field>
  <title>OS</title>
  ...
</custom-field>

JSON

{"custom_field":{"title":"OS",...}}

Query string

custom_field[title]=OS&...

Check the full list of available params on custom field object fields reference

Examples

For example purposes we use a JSON body

{"custom_field":{"title":"OS"}}

Request XML, using cURL utility:

curl -i -H "Authorization: Bearer _token" -H "Content-type: application/json" -d '{"custom_field":{"title":"OS"}}' https://api.assembla.com/v1/spaces/_space_id/tickets/custom_fields.xml

Response

HTTP/1.1 201 Created
Server: nginx/0.8.55
Date: Mon, 24 Sep 2012 12:47:08 GMT
Content-Type: application/xml; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 201
Location: http://api.assembla.com/v1/spaces/_space_id/tickets/custom_fields/_id
...

<?xml version="1.0" encoding="UTF-8"?>
<custom-field>
  <id type="integer">19</id>
  <space-tool-id>dP3FZG_ber4B8UadbNA33N</space-tool-id>
  <type>Text</type>
  <title>OS</title>
  <order nil="true"></order>
  <required type="boolean">false</required>
  <hide type="boolean">false</hide>
  <default-value nil="true"></default-value>
  <created-at type="datetime">2012-09-24T12:47:08Z</created-at>
  <updated-at type="datetime">2012-09-24T12:47:08Z</updated-at>
</custom-field>

Request JSON, using cURL utility:

curl -i -H "Authorization: Bearer _token" -H "Content-type: application/json" -d '{"custom_field":{"title":"OS"}}' https://api.assembla.com/v1/spaces/_space_id/tickets/custom_fields.json

Response

HTTP/1.1 201 Created
Server: nginx/0.8.55
Date: Mon, 24 Sep 2012 12:48:12 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 201
Location: http://api.assembla.com/v1/spaces/_space_id/tickets/custom_fields/_id
...

{
  "id":20,
  "space_tool_id":"dP3FZG_ber4B8UadbNA33N",
  "type":"Text",
  "title":"OS",
  "order":null,
  "required":false,
  "hide":false,
  "default_value":null,
  "created_at":"2012-09-24T12:48:12Z",
  "updated_at":"2012-09-24T12:48:12Z"
}

JSON is formatted here for readability, in a real response JSON body is inline with no indentation.

Note: pay attention to Location header, this is the URL where newly created resource is located, you can GET on this URL to access this resource.

Description for each field: custom field object fields reference