2 Replies Latest reply on Jan 25, 2017 6:00 AM by jkaczynski-2 RSS
    steveash Newbie

    Is there a way to access response headers from a GetJSON() call in a service?

    I'm working with an external service where I request a csrf token via request header and the service returns the token in the response headers.  I can't see how to access the response headers in my Thing service.

     

    For example, here's the call to GetJSON:

     

    var params = {

        headers: {'x-csrf-token' : 'fetch'} /* JSON */,

    ignoreSSLErrors: true /* BOOLEAN */,
    url: me.baseURL /* STRING */,
    password: me.password /* STRING */,
    username: me.userId /* STRING */

    };

     

    // result: JSON

    var result = Resources["ContentLoaderFunctions"].GetJSON(params);

     

    I can see my request headers in the output if I logger.warn(JSON.stringify(result)); (i.e.  {"headers":{"x-csrf-token":"fetch"}) but when I execute the same GET from POSTMAN and look at the response headers, I see the other system's returned value for x-csrf-token.

     

    Is there a way to access the response headers in a service?

     

    Thanks,

    Steve Ashley