Calling Ticket API from script.js within Zendesk Help Centre - CORS issue

3 コメント

  • Pulkit Pandey
    Community Moderator
    Zendesk Luminary

    Hi Imran Ali

    If you're looking for a quick and efficient way to list the tickets of the same help center in which you're writing your code in a script js file, the Zendesk API is the perfect solution for you. By making a GET request to the /api/v2/tickets endpoint, you can easily retrieve a list of tickets in that help center. Once you parse the JSON response, you can display the tickets as desired. 

    Please replace the below code with your, it will give a list of tickets on your helpcenter 

        url: '/api/v2/tickets',
        type: 'GET',
        dataType: 'json',
        success: function (data) {
        error: function (xhr, status, error) {


    Don't hesitate to let me know if you need any further assistance!


    Thank You 


    Team Diziana

  • Rafael Santos
    User Group Leader

    I'd like to strongly disrecommend storing Auth data in your theme, be it on script.js or other.

    If you're interested in showing your end-user's tickets, you could use the Requests API using their own CSRF tokens to authenticate.

    An example is available on the Developer Documentation > Making secured API requests from a help center

    Additionally, it'll be a good practice to add a caching/throttling mechanism to those calls, as to avoid hitting an API rate limit.

  • Mr Vyas

    Thank you so much for the best platform. I always use this platform for getting help. I am going to share this platform with my friends as well. Thanks again.



Powered by Zendesk