Update Zendesk User - Where did I go wrong?

I went through quite some trial and error (403 and 422 specifically) to fire a successful PUT request to the Zendesk API. While I thought I got the hang of it, because the requests to our own API (all POST and GET) were done so easily.

Here's what I ended up with:

linkCustomer: function(customer_id) { var data = '{ "user": { "external_id": ' + customer_id + ' } }'; return { url: '/api/v2/users/' + this.ticket().requester().id() +'.json', type: 'PUT', data: data, dataType: 'json', contentType: 'application/json; charset=UTF-8', processData: false }; }

With a POST request to an own API (through the proxy) the data object seemed to be parsed to JSON automatically. With this PUT request to the Zenddesk API I had to pass the JSON object as a string.

One of my other calls looks like this:

getCustomer: function(external_id) { return { url: 'http://www.domain.com/zendesk/api/getCustomer';, type: 'POST', data: { customer_id: external_id }, dataType: 'json' }; }


So the code I started my trial and error with looked somewhat like the code below. But gave me a 403 error, until I added the contentType parameter. Which gave me the 422 error, until i passed the JSON as a string and set the processData parameter to false.

linkCustomer: function(customer_id) { return { url: '/api/v2/users/' + this.ticket().requester().id() +'.json', type: 'PUT', data: { user: { customer_id: external_id } }, dataType: 'json' }; }


So that makes me believe the code I ended up with is incorrect (although it's functional correct). Could somebody point me in the right direction?


Please sign in to leave a comment.