Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X
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
Hi Steve,
I don't know if that's the reason, but it's not the same doing a request with POSTMAN and with TW, as POSTMAN automatically adds requests headers which can affect to response headers.
Carles.
Hi Steve,
I believe there is no such possibility OOTB now (but I can be wrong). The easiest way to achieve that is to create a very simple extension in Java with generic service to send HTTP requests. Then you can do pretty much anything with response. This is the most clean and straightforward solution.
Regards,
J.