Need remote address/IP from a scoped Scripted REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
You can try with it:
gs.log("IP address: " + request.headers["x-forwarded-for"], "HEADERS");
OR
var reqHeader = request.headers;
var jsonObj = new JSON();
var headerStr = jsonObj.encode(reqHeader);
gs.log('headers'+headerStr);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thursday
What are you doing with the ip? If it's for whitelisting you could use rest api access policies.
Unauthenticated transactions will still have a jsessionid and will just use the guest user as a proxy. You can get the session id in a scoped script with gs.getSessionID(). With the sessionid it should be trivial to get the ip from the transaction log but the transaction is not logged before the transaction is finished. Maybe it's possible on the fly from somewhere else.
