Search code examples
restpostcurlhttp-postzendesk

Zendesk API - Creating a ticket gives wrong ticket status


Zendesk API documentation states that when creating a ticket through the API, the status field can be set to "new" (https://developer.zendesk.com/rest_api/docs/core/tickets#create-ticket), yet if I call the API with the following command specifying a value for status, it creates a token yet still sets status to be the default value of open:

curl -u <username>/token:<api_token> https://<subdomain>.zendesk.com/api/v2/tickets.json -d '{"ticket": {"subject":"test subject", "comment": { "body": "test body" }, "status": "new" } }' -H "Content-Type: application/json" -v POST

The relevant part of the response body is:

"ticket": { "url": "https://<subdomain>.zendesk.com/api/v2/tickets/60.json", "id": 60, "external_id": null, "via": { "channel": "api", "source": { "from": {}, "to": {}, "rel": null } }, "created_at": "2016-05-05T13:30:01Z", "updated_at": "2016-05-05T13:30:01Z", "type": null, "subject": "test subject", "raw_subject": "test subject", "description": "test body", "priority": null, "status": "open", "recipient": null, "requester_id": 5917202647, "submitter_id": 5917202647, "assignee_id": 5917202647, "organization_id": 3740197137, "group_id": 28473587, "collaborator_ids": [], "forum_topic_id": null, "problem_id": null, "has_incidents": false, "due_at": null, "tags": [], "custom_fields": [], "satisfaction_rating": null, "sharing_agreement_ids": [], "fields": [], "brand_id": 1090897, "allow_channelback": false }

Am I doing something wrong?


Solution

  • So it turns out that if you assign a ticket to a group with only one member/agent, the ticket automatically gets assigned to that lone agent. As such, any ticket that's already assigned to a specific agent, is automatically set to open instead of new.

    Because I was using a test subdomain, I was the only agent and so it was auto-updating the status from "new" to "open".