Zendesk Apps tutorial - Getting data from an external application Follow

Comments

6 comments

  • Avatar
    Krzy Hamer

    Hi, is there any chance to get data from RESPONSE Headers while using ZAFClient.request?
    I'm getting only the body as one argument in a response.

  • Avatar
    Jessie - Community Manager

    Welcome to the Community Krzy! Let me see if I can find an answer for you on this. Stand by!

  • Avatar
    Rebecca

    Hey Krzy - 

    Sorry for the delay here! In test I wasn't able to find a way to get response headers when using client.request. 


    var fetchSelf = {
      url: '/api/v2/tickets/123.json',
      type: 'GET',
      dataType: 'json'
    };

    function doit() {
    client.request(fetchSelf).then(function(data) {
      console.dir(data);
      console.log(data.headers);
    })
    };

    I would always get an undefined response: 


    I reached out to our Product team and they confirmed client.request only returns the data object; it will not return response headers. Our Product team has however added this as a feature request for the Apps Framework roadmap. Sorry for the limitation here!

    For some background, here's how client.request operates on the backend:

    The options passed to request are sent to the framework via postMessage and then given to jQuery.ajax, so all options jQuery supports that can be converted to JSON will, in theory work. For example, headers can be passed since it's a plain object, whereas beforeSend will not since functions cannot be converted to JSON. 

  • Avatar
    Krzy Hamer (Edited )

    [SOLVED]

    For people interested - You can make a request to Zendesk Core Api by ZAFClient.request method inside your custom app.


    [Original question:]

    HI, I don't know if it is a proper secction, but can my private app make request to zendesk core api? 

    I need my app to check which Zendesk user is currently using Zendesk.

    I can get this by api/v2/users/me/session.json - but i cannot make this call via my application (401 - unauthorized).
    Is there a way to check user id & parameters (api/v2/users/{id})?

  • Avatar
    Jeroen van der Sandt

    Hello,

    do the secure settings only work in headers? I'd like to use them as part of a request url.

    Thanks,

    Jeroen

  • Avatar
    Bryan Flynn

    Hi Jeroen. Yes, if you're writing a server-side app (where you host the assets and the app manifest location is a remote URL) you can also reference a secure setting in that manifest location URL.

    Since you're looking at secure settings, I'd also recommend looking through this article: Making API calls with Zendesk Apps framework (ZAF), ZAF proxy, and help with CORs.

Please sign in to leave a comment.

Powered by Zendesk