Building a server-side app - Part 2: Display server-side content in a Zendesk app

Have more questions? Submit a request

3 Comments

  • Michal Wysocki
    Comment actions Permalink

    I just created a simple MVC app in Visual Studio. My App is hosted on our server:


    https://X.X.X.X/ The app loads fine in ZenDesk but if I click the link to different page e.g. https://X.X.X.X/Account/Login the app displays blank screen. The console shows the following error: Refused to display 'https://X.X.X.X/Account/Login' in a frame because it set 'X-Frame-Options' to 'sameorigin'.


     

    0
  • Tom
    Comment actions Permalink

    Hi, 

    I would like to build an app where the support agents could report a bug and it would be sent to google sheet for a further investigation. 

    One of the function needed is the ticket's url that has to be sent to the google sheet. It seems that I cannot access the ticket url from the app in iframe and assign it to the variable with js. The error I receive is "Blocked a frame with origin "https://248092.apps.zdusercontent.com" from accessing a cross-origin frame."

    console.log(window.parent.location.href);

    It would be great if someone could let me know whether there is a way to access ticket's url? 

    0
  • Charles Nadeau
    Comment actions Permalink

    Hi Tom,

    You can access the Support REST API directly using `client.request()` (https://developer.zendesk.com/apps/docs/developer-guide/using_sdk#working-with-requests) and grab the url from the Tickets API (https://developer.zendesk.com/rest_api/docs/support/tickets#json-format).

    Back-of-the-envelope example with no testing:

    (function(){
      // create ZAF client
      const client = ZAFClient.init();
    
      // get the ticket id
      client.get('ticket.id')
      .then(function (data) {
        ticket_id = data['ticket.id'];
        return;
      })
    
      // make the Support API request
      .then(function () {
        const settings = {
          type: 'GET',
          url: '/api/v2/tickets/' + ticket_id + '.json'
        };
        client.request(settings)
    
        // extract the ticket url
        .then(function (data) {
          console.log(data['ticket']['url']);
        })
      })
    })();

     

     

    0

Please sign in to leave a comment.

Powered by Zendesk