HTTP Verb: POST

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

Object: Ticket

Location: available

Formats: XML, JSON

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

Params

To create a ticket, 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 ticket namespace, e.g.:

XML

<ticket>
  <summary>FixMe</summary>
  ...
</ticket>

JSON

{"ticket":{"summary":"FixMe",...}}

Query string

ticket[summary]=FixMe&...

Check the full list of available params on ticket object fields reference

Examples

For example purposes we use a JSON body

{"ticket":{"summary":"FixMe"}}

Request XML, using cURL utility:

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

Response

HTTP/1.1 201 Created
Server: nginx/0.8.55
Date: Wed, 20 Jun 2012 12:13:01 GMT
Content-Type: application/xml; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 201
Location: http://api.assembla.com/v1/spaces/test-1/tickets/157-FixMe
...

<?xml version="1.0" encoding="UTF-8"?>
<ticket>
  <status type="integer">1</status>
  <summary>FixMe</summary>
  <total-estimate type="float">1.0</total-estimate>
  <estimate type="float">1.0</estimate>
  <notification-list>bgnP_qA1Gr2QjIaaaHk9wZ</notification-list>
  <description nil="true"></description>
  <total-working-hours type="float">0.0</total-working-hours>
  <total-invested-hours type="float">0.0</total-invested-hours>
  <permission-type type="integer">1</permission-type>
  <space-id>b89TL8MYWr4id7adbNA33N</space-id>
  <assigned-to-id nil="true"></assigned-to-id>
  <updated-at type="datetime">2012-06-20T12:13:01Z</updated-at>
  <story-importance type="integer">0</story-importance>
  <working-hours type="float">0.0</working-hours>
  <milestone-id nil="true"></milestone-id>
  <reporter-id>bgnP_qA1Gr2QjIaaaHk9wZ</reporter-id>
  <created-on type="datetime">2012-06-20T12:13:01Z</created-on>
  <custom-fields>
    <list>FixMe</list>
    <Text-Field></Text-Field>
  </custom-fields>
  <status-name>New</status-name>
  <is-story type="boolean">false</is-story>
  <completed-date nil="true"></completed-date>
  <id type="integer">2191</id>
  <importance type="float">16.0</importance>
  <component-id nil="true"></component-id>
  <priority type="integer">3</priority>
  <number type="integer">157</number>
</ticket>

Request JSON, using cURL utility:

curl -i -H "Authorization: Bearer _token" -H "Content-type: application/json" -d '{"ticket":{"summary":"FixMe"}}' https://api.assembla.com/v1/spaces/_space_id/tickets.json

Response

HTTP/1.1 201 Created
Server: nginx/0.8.55
Date: Wed, 20 Jun 2012 12:05:41 GMT
Content-Type: application/json; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 201
Location: https://api.assembla.com/v1/spaces/test-1/tickets/156-FixMe
...

{
  "completed_date":null,
  "updated_at":"2012-06-20T12:05:41Z",
  "total_working_hours":0.0,
  "status_name":"New",
  "created_on":"2012-06-20T12:05:41Z",
  "assigned_to_id":null,
  "permission_type":1,
  "id":2190,
  "total_estimate":1.0,
  "number":156,
  "importance":15.0,
  "custom_fields":{"list":"FixMe","Text Field":""},
  "working_hours":0.0,
  "summary":"FixMe",
  "space_id":"b89TL8MYWr4id7adbNA33N",
  "total_invested_hours":0.0,
  "notification_list":"bgnP_qA1Gr2QjIaaaHk9wZ",
  "component_id":null,
  "story_importance":0,
  "estimate":1.0,
  "status":1,
  "reporter_id":"bgnP_qA1Gr2QjIaaaHk9wZ",
  "is_story":false,
  "description":null,
  "priority":3,
  "milestone_id":null
}

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

Note: If you want to add a value to a custom field, to identify the custom fields an ID or name should be provided, name should be formatted to match XML, JSON or query string acceptable format, i.e.:

  • JSON, replace whitespaces with underscores - “Text Field” should be “Text_Field”
  • XML, replace whitespaces with dashes - “Text Field” should be “Text-Field”
  • Query string, replace whitespaces with underscores - “Text Field” should be “Text_Field”

Examples of valid custom fields body, considering ID of a custom field is “15” and its title is “Text Field”:

JSON:

{"ticket":{"custom_fields":{"Text_Field":"some value"}}}

{"ticket":{"custom_fields":{"15":"some value"}}}

XML:

<ticket>
  <custom-fields>
    <Text-Field>some value</Text-Field>
  </custom-fields>
</ticket>

XML does not support identifiyng custom fields by ID which is an integer, a integer can’t be a valid XML tag

Query string:

ticket[custom_fields][Text_Field]=some value

ticket[custom_fields][15]=some value

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: ticket object fields reference