0

Bug: Updating Ticket's comment via Lotus App's Ajax call fails

Reference:

http://developer.zendesk.com/documentation/rest_api/tickets.html#updating-tickets

Hi

I am wanting to update a ticket's comments through the Lotus App using an Ajax call by following the aforementioned reference.

  1. In providing within request data = "comment: { public: " fails JSHint

Upload Error

         JSHint error(s): L619: Expected an identifier and instead saw 'public' (a reserved word).

  1. Request: Maybe rename comment's public: to either public_reply: or internal_note: so upload will pass JSHint.

  2. In making the request (without public attribute in comment JSON body) it fails

Here is the function making the PUT request to update the ticket:

putTicketComment: function(data) { var currentAccount = this.currentAccount(); var ticket = this.ticket(); var subdomain = currentAccount.subdomain(); var id = ticket.id(); var url = 'https://%@.zendesk.com/api/v2/tickets/%@.json'.fmt(subdomain, id) return { url: url, type: 'PUT', dataType: 'JSON', data: data }; }

And here is the code calling putTicketComment with defined data (notice that I commented out public: to pass JSHint at upload:

var data = { ticket: { status: ticket.status(), comment: { // public : true, value: 'Hello, World!!!' } } }; this.ajax('putTicketComment', data);

The failure response to 'putTicketComment.fail' was as follows:

Put ticket comment failed:

    jqXHR = {    status: 200,    statusText: OK,    responseText: Invalid URL parameter    },

    textStatus = parsererror

So, error is with the provided data, because my built url looks okay:

  url = https://jeff00tangocard.zendesk.com/api/v2/tickets/5.json

Thanks for your assistance,

  • Jeff

12 comments

  • 0
    1. Put "public" in quotes to hint that you are using it as a string. JSHint should allow that.

    2. When making AJAX calls to your own zendesk, you should use relative URLs. This is a deficiency in the way we determine whether to proxy your AJAX request or not, but you can get around that for now by using relative URLs.

  • 0

    Hi

    For this problem, please provide example "using relative URLs".

    Are you requesting that instead of using:

     url = https://jeff00tangocard.zendesk.com/api/v2/tickets/5.json

    I should be using:

     url = api/v2/tickets/5.json

    Thx

    • Jeff
  • 0

    In addition, putting quotes around keys within JSON defined data may pass JSHint, but that would be inconsistent with Lotus App documentation:

    http://developer.zendesk.com/documentation/apps/requests.html#more-in-depth

    I would request that to rename "public:' to a non-reserved name so that other developers run into the same issue.

    Thx

    • Jeff
  • 0

    Hi

    Tried with quoted 'public' in data:

    var data = {   ticket: {     status: ticket.status(),     comment: {       'public' : true,       value: 'Hello, World!!!'     }   } };

    And relative url:

    var url = api/v2/tickets/5.json

    But it still errors

    *jqXHR = { status: 405, statusText: Not Allowed, responseText: 405 Not Allowed nginx/1.0.15 }, *

    textStatus = error

    I appreciate your assistance,

    • Jeff
  • 0

    Tried same data (with quoted 'public') but with full url:

    var  url = https://jeff00tangocard.zendesk.com/api/v2/tickets/5.json

    and got same initial error:

        jqXHR = {    status: 200,    statusText: OK,    responseText: Invalid URL parameter    },

        textStatus = parsererror

  • 0

    The problem with AJAX requests using full help desk URLs is a  known issue.

  • 0
    1. By "full help desk URLs" , do you mean " https://jeff00tangocard.zendesk.com/api/v2/tickets/5.json" versus using "relative URLs", like " api/v2/tickets/5.json"

    2. Thanks for the known issue link, but this was a known issue in May. When will this be addressed?

    Thanks

    • Jeff
  • 0
    1. That's correct.

    2. The errata document was originally authored in May, but we update it regularly. I believe I added the item about AJAX requests on Wednesday.

  • 0

    Thx

    • Jeff
  • 0

    Hi James

    Thx for the "Root-relative" info, and I tried the following:

         var ticket = this.ticket();

         var id = ticket.id();

         var url = '/api/v2/tickets/%@.json'.fmt(id;

    (which its product is url =** /api/v2/tickets/5.json**)

    But this errors as well:

    jqXHR = { status: 403, statusText: Forbidden, responseText: { "error": { "title": "Forbidden", "message": "" } } } textStatus = error

    Sorry, but what is the next step???

    Respectfully

    • Jeff
  • 0

    I would suggest trying going to the (full) URL in your browser. If that also returns a 403, it's likely that your current user doesn't have access to that ticket. If it doesn't, I'd try again as an AJAX call from the console: jQuery.ajax({ url: '/api/v2/tickets/5.json' }) . If that returns a 403, then I'll investigate why AJAX calls don't have access to that URL. If that returns a 200, though, then the problem is in the app and you should submit a ticket and attach the app source.

  • 0

    Hi again

    I tried both suggested tests, and I had experienced no 403 problems.

    Using Chrome, I logged into my Zendesk desktop

    1. Was able to view ticket's JSON object using full-path
    2. ran jQuery.ajax({ url: '/api/v2/tickets/5.json' }) from Chrome console using root-path, was able to see JSON object

    Thx for your assistance

    • Jeff

     

    /api/v2/tickets/5.json

Please sign in to leave a comment.